OpenSAML how to check if SAML Response (signature/cert) is really from my IDP?

拟墨画扇 提交于 2019-12-06 15:49:24

First things first :

Don't roll your own SAML implementation . There are just too many things you can get wrong that it's not worth the risk. I don't know if I can stress this enough. Use an open source, well known and tested implementation like Shibboleth SP or simplesamlphp

Warning above aside, and assuming you are doing this for your own understanding and not as part of a product/service that will be available to anyone but you:

The way to check that the response comes from your IDP is to check the the Digital Signature. For that, you must use the Public Key of the IDP (that is contained in the IDP certificate which you know from the IDPs metadata) in order to verify the Digital Signature. Please read about Digital Signatures, Digital Signature verification to understand what needs to be done and why. Then you can proceed on the how to do it by reading the Official Documetnation. Some notes:

  • Don't trust the certificate that comes with the SAML Assertion. This is there just for the case you know multiple certs for a given Relying Party and you need to select the one that applies to the specific SAML conversation.
  • You can't do String comparison on the Signature. You cannot compute the same Signature as you don't have the Private Key that the IdP used to create it.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!