【问题标题】:Azure B2C with custom SAML2 policy and Sha256 as the signing algorithm使用自定义 SAML2 策略和 Sha256 作为签名算法的 Azure B2C
【发布时间】:2020-03-30 22:51:39
【问题描述】:

我正在使用 Sustainsys 包 Sustainsys.Saml2.AspNetCore2 在 ASP.NET Core 3.1 中构建服务提供商 Web 应用程序,它使用 Azure B2C 作为身份提供商,使用 SAML2。我有以下问题:

  1. 如果我使用Sha1 作为签名算法,使用选项MinIncomingSigningAlgorithm,那么CryptoConfig.CreateFromName 会抛出异常,因为该方法不知道Sha1 算法。

  2. 如果我使用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


    【解决方案1】:

    事实证明,我还需要将&lt;Item Key="XmlSignatureAlgorithm"&gt;Sha256&lt;/Item&gt; 添加到技术配置文件中(除了它是 RelyingParty 的一部分,如上所示)。这解决了我在单次注销时遇到的问题。

    <TechnicalProfile Id="Saml2AssertionIssuer">
      <Protocol Name="None"/>
      <OutputTokenFormat>SAML2</OutputTokenFormat>
      <Metadata>    
        <Item Key="XmlSignatureAlgorithm">Sha256</Item>
      </Metadata>
    </TechnicalProfile>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-01-24
      • 1970-01-01
      • 2019-03-14
      • 2020-10-29
      • 1970-01-01
      • 2019-10-01
      • 1970-01-01
      相关资源
      最近更新 更多