C# 在C中签名和发布SAML文件#

C# 在C中签名和发布SAML文件#,c#,single-sign-on,saml,saml-2.0,C#,Single Sign On,Saml,Saml 2.0,我正在尝试使用SAML实现单点登录。idp向我发送的请求样本如下: <samlp:AuthnRequest xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" AssertionConsumerServiceURL="https://client1.com/MyBank1/ReceiveSAMLResponse" Destination=" https://tawtheeq.sa/identity-gateway/ReceiveSAMLRe

我正在尝试使用SAML实现单点登录。idp向我发送的请求样本如下:

<samlp:AuthnRequest xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"
AssertionConsumerServiceURL="https://client1.com/MyBank1/ReceiveSAMLResponse"
Destination=" https://tawtheeq.sa/identity-gateway/ReceiveSAMLRequest"
ForceAuthn="false" ID="9eff699e-6e2c-487c-940f-1f67c226f423" IsPassive="false"
IssueInstant="2018-02-05T07:49:14.992Z" ProtocolBinding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"
Version="2.0">
<saml:Issuer xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"> https://client1.com/</saml:Issuer>
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
    <ds:SignedInfo>
        ...
    </ds:SignedInfo>
    <ds:SignatureValue>
        tKSzhWGSv...FPbhwPQ==
    </ds:SignatureValue>
    <ds:KeyInfo>
        <ds:X509Data>
            <ds:X509Certificate>MIIDZz...tlak4=</ds:X509Certificate>
        </ds:X509Data>
    </ds:KeyInfo>
</ds:Signature>
<samlp:NameIDPolicy AllowCreate="true"
    Format="urn:oasis:names:tc:SAML:2.0:nameid-format:persistent" />
<samlp:RequestedAuthnContext Comparison="exact">
    <saml:AuthnContextClassRef xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport
    </saml:AuthnContextClassRef>
</samlp:RequestedAuthnContext>
代码中的签名XML不正确,并且在我尝试发布文件时无法正常工作:

<SignedInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
<CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n- 
20010315" />
<SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />
<Reference URI="">
 <Transforms>
  <Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped- 
signature" />
</Transforms>
<DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
<DigestValue>zSI5ZAMmQ+8u7R2rP7aAPT6nNQw=</DigestValue>
</Reference>
</SignedInfo>
<SignatureValue xmlns="http://www.w3.org/2000/09/xmldsig#">EncryptedKey</SignatureValue>

zSI5ZAMmQ+8u7R2rP7aAPT6nNQw=
加密密钥
注意:我从签名的xml中删除了加密密钥

我的问题是:

  • 这就是为什么这次集成bcz是我第一次使用SAML SSO的原因
  • 在这种情况下,Keystore有什么用途
  • 如果你能与我分享任何关于这个话题的有用文章,我将不胜感激
    谢谢

    您是否找到了解决此问题的方法。我也在找。
    <SignedInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
    <CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n- 
    20010315" />
    <SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />
    <Reference URI="">
     <Transforms>
      <Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped- 
    signature" />
    </Transforms>
    <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
    <DigestValue>zSI5ZAMmQ+8u7R2rP7aAPT6nNQw=</DigestValue>
    </Reference>
    </SignedInfo>
    <SignatureValue xmlns="http://www.w3.org/2000/09/xmldsig#">EncryptedKey</SignatureValue>