当我们正在开发一个我们想要针对 Shibboleth IDP 授权的 web 应用程序时,我们收到以下错误,在 IDPP 成功登录之后:
处理请求时发生未处理的异常。
UnexpectedInResponseToException:收到的消息包含意外的 InResponseTo“idd95739d3bc9e44efa1154b3e62a2e121”。未找到来自请求的 cookie 保留状态,因此消息不应具有 InResponseTo 属性。如果在执行 SP 启动的登录时设置的 cookie 丢失,通常会发生此错误。
Sustainsys.Saml2.Saml2P.Saml2Response.ReadAndValidateInResponseTo(XmlElement xml, Saml2Id expectedInResponseTo, IOptions options) in Saml2Response.cs, line 153
我们的 startup.cs 看起来像这样:
services.AddAuthentication()
.AddSaml2(options =>
{
options.SPOptions.EntityId = new EntityId("https://adress.to.the.SP.net");
options.SPOptions.Compatibility.UnpackEntitiesDescriptorInIdentityProviderMetadata = true;
options.SPOptions.ReturnUrl = new Uri(@"https://adress.to.a.site.of.our.site.net.net/Saml/Session");
options.SPOptions.ServiceCertificates.Add(new X509Certificate2(@"wwwroot/mycert.pfx")); // "Sustainsys.Saml2.Tests.pfx"
options.IdentityProviders.Add(
new IdentityProvider(
new EntityId("adress.to.the.IDP.net"), options.SPOptions)
{
LoadMetadata = true,
MetadataLocation = ("https://adress.to.the.MetadataLocation.xml")
});
IdentityProvider idp;
var x = options.IdentityProviders.TryGetValue(new EntityId(Prov.Idp), out idp);
X509Certificate2 ssoTest = new X509Certificate2(@"wwwroot/sso-test.pem");
idp.SigningKeys.AddConfiguredKey(ssoTest); …Run Code Online (Sandbox Code Playgroud)