某些SAML响应的CheckSignature失败。 [英] CheckSignature on some SAML responses fails.

查看:109
本文介绍了某些SAML响应的CheckSignature失败。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi Team,


我们已实施SAML身份验证并使用.Net framework 4.6.2


CheckSignature在某些SAML上失败答复,到目前为止我们已经找到了一个这样的案例CheckSignature会通过所有其他SAML回复。


1。 SAML响应有效


2。证书有效


3。 SAML响应文本未被更改。



在网络上发现此文章 - >  https://github.com/dotnet/corefx/issues/19198


以下是检查SAML响应上的签名的代码。


  XmlNamespaceManager manager = new XmlNamespaceManager(xmlDoc.NameTable);

            manager.AddNamespace(" ds",SignedXml.XmlDsigNamespaceUrl);

            manager.AddNamespace(" saml"," urn:oasis:names:tc:SAML:2.0:assertion");

            manager.AddNamespace(" samlp"," urn:oasis:names:tc:SAML:2.0:protocol");



            XmlNodeList nodeList = xmlDoc.SelectNodes(" // ds:Signature",manager);



            SignedXml signedXml = new SignedXml(xmlDoc);



            if(nodeList?.Count!= 1)

            {

               返回false;

            }


            //从SAML响应加载signedXml 



            signedXml.LoadXml((XmlElement)nodeList [0]);
$


            //从文件存储区加载证书

            X509Certificate2 cert =(来自文件存储的证书。)



            //使用签名和密钥签名证书中的公钥进行Verifiy签名。



            return(signedXml.CheckSignature()|| signedXml.CheckSignature(cert,true));




<请告诉我,如果我在这里遗漏任何东西。


问候,


Prashant。

解决方案

您好Prashant Dudami,


感谢您在此发帖。


为您服务问题,请查看以下链接。


http ://doc.componentpro.com/ComponentPro-Saml/ComponentPro-Saml-SignableSamlObject-Validate()


最好的问候,


温迪


Hi Team,

We have implemented SAML authentication and using .Net framework 4.6.2

CheckSignature is failing on some SAML responses, so far we have found one such case. CheckSignature passes for all other SAML responses.

1. SAML response is valid

2. Certificate is valid

3. SAML response text was not altered.

Found this article on the web --> https://github.com/dotnet/corefx/issues/19198

Here is the code which checks signature on SAML response.

 XmlNamespaceManager manager = new XmlNamespaceManager(xmlDoc.NameTable);
            manager.AddNamespace("ds", SignedXml.XmlDsigNamespaceUrl);
            manager.AddNamespace("saml", "urn:oasis:names:tc:SAML:2.0:assertion");
            manager.AddNamespace("samlp", "urn:oasis:names:tc:SAML:2.0:protocol");

            XmlNodeList nodeList = xmlDoc.SelectNodes("//ds:Signature", manager);

            SignedXml signedXml = new SignedXml(xmlDoc);

            if (nodeList?.Count != 1)
            {
                return false;
            }

            //Load signedXml from SAML Response 

            signedXml.LoadXml((XmlElement) nodeList[0]);

            // Load certificate from file store
            X509Certificate2 cert = (certificate from file store.)

            //Verifiy signature using the public key in the signature and key signing ceritificate.

            return (signedXml.CheckSignature() || signedXml.CheckSignature(cert, true));

Please let me know, if there I am missing anything here.

regards,

Prashant.

解决方案

Hi Prashant Dudami,

Thank you for posting here.

For your question, please check the following link.

http://doc.componentpro.com/ComponentPro-Saml/ComponentPro-Saml-SignableSamlObject-Validate()

Best Regards,

Wendy


这篇关于某些SAML响应的CheckSignature失败。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆