更新
我发现,如果我向SPOptions.ServiceCertificates添加了一个可信证书,并设置了SPOptions.AuthenticateRequestSigningBehavior = Sustainsys.Saml2.Configuration.SigningBehavior.IfIdpWantAuthnRequestsSigned;和IdentityProvider.WantAuthnRequestsSigned = true,则包含签名元素。
原题:
使用以下AuthnRequest连接到IDP时遇到问题
<saml2p:AuthnRequest xmlns:saml2p="urn:oasis:names:tc:SAML:2.0:protocol" xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion" ID="idf299bf8aa08542d193e022cb047e5ecc" Version="2.0" IssueInstant="2019-07-23T00:10:13Z" Destination="https://example-idp.com" AssertionConsumerServiceURL="https://example-sp.com/Acs">
<saml2:Issuer>https://example-sp.com</saml2:Issuer>
</saml2p:AuthnRequest>国内流离失所者说:"SignatureStatus: NOT_PRESENT"。我猜这意味着authnrequest应该有一个<ds:Signature部分?如果是这样的话,我如何配置Sustainsys.Saml2.AspNetCore2以包括它?
我从idp收到的元数据xml包含一个<ds:Signature部分,但是看看Sustainsys.Saml2.AspNetCore2的源代码,它看起来就像是在反序列化时忽略了元数据的那一部分吗?
我不太熟悉SAML的内部结构,如果这是一个愚蠢的问题,我很抱歉。
发布于 2019-07-23 20:57:37
您将需要生成一个包含公共证书和私钥的自签名.pfx文件。我们使用天蓝色密钥库,但您也可以使用openssl。许多资源解释了如何生成其中之一并将其加载到c# X509Certificate2实例中。
拥有X509Certificate2实例后,设置options.SPOptions.AuthenticateRequestSigningBehavior = Sustainsys.Saml2.Configuration.SigningBehavior.IfIdpWantAuthnRequestsSigned;
并设置IdentityProvider.WantAuthnRequestsSigned = true。
然后添加X509Certificate2实例,如:options.SPOptions.ServiceCertificates.Add(myX509Certificate2);
然后运行您的应用程序并启动SAML进程。您可以使用hookbin或类似的方式查看它在AuthnRequest for SAMLRequest中发送的内容。您可以通过url解码从xml中提取xml,然后按照javascript的方式对其进行base64解码,例如,以确认已设置并更正了签名xml:atob(decodeURIComponent(samlRequestValue))。
https://stackoverflow.com/questions/57155482
复制相似问题