【发布时间】:2020-03-30 22:51:39
【问题描述】:
我正在使用 Sustainsys 包 Sustainsys.Saml2.AspNetCore2 在 ASP.NET Core 3.1 中构建服务提供商 Web 应用程序,它使用 Azure B2C 作为身份提供商,使用 SAML2。我有以下问题:
-
如果我使用
Sha1作为签名算法,使用选项MinIncomingSigningAlgorithm,那么CryptoConfig.CreateFromName会抛出异常,因为该方法不知道Sha1算法。 如果我使用
Sha256作为签名算法,那么即使我在自定义策略的RelyingParty中指定了<Item Key="XmlSignatureAlgorithm">Sha256</Item>,Azure B2C 也会使用Sha1对响应进行签名。 我应该注意,这似乎只发生在服务提供商启动单一注销流程时。 登录流程完成时没有问题,并且签名算法是Sha256。这是我的 RelyingParty 部分:
<RelyingParty>
<DefaultUserJourney ReferenceId="SignUpOrSignIn" />
<TechnicalProfile Id="PolicyProfile">
<DisplayName>PolicyProfile</DisplayName>
<Protocol Name="SAML2"/>
<Metadata>
<Item Key="XmlSignatureAlgorithm">Sha256</Item>
</Metadata>
<OutputClaims>
<OutputClaim ClaimTypeReferenceId="displayName" />
<OutputClaim ClaimTypeReferenceId="givenName" />
</OutputClaims>
<SubjectNamingInfo ClaimType="objectId" ExcludeAsClaim="true"/>
</TechnicalProfile>
</RelyingParty>
此外,Azure B2C 的元数据使用Sha256 作为签名和摘要方法。以下是相关部分:
<SignedInfo>
<CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
<SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/>
<Reference URI="...">
<Transforms>
<Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
<Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
<InclusiveNamespaces xmlns="http://www.w3.org/2001/10/xml-exc-c14n#" PrefixList="saml samlp xenc xs"/>
</Transform>
</Transforms>
<DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
</Reference>
</SignedInfo>
非常感谢任何帮助。谢谢。
【问题讨论】:
标签: asp.net-core azure-ad-b2c sustainsys-saml2