Good day,
We used ITfoxtec library version 1.2.2. This solution worked correctly.
We are now integrating the version 4.0.5 library. We need to use SHA-256 encoding. We used the 4.0.5 library from Nugets. According to the implementation example https://github.com/ITfoxtec/ITfoxtec.Identity.Saml2.
The SAML request was sent successfully. Arrived SAML response. Exception is throw on the method AssertionConsumerService() in line binding.ReadSamlResponse(Request.ToGenericHttpRequest(), saml2AuthnResponse);.
Throw exception: ITfoxtec.Identity.Saml2.Saml2RequestException: 'There is not exactly one Assertion element.'
This is my SAML response:
<samlp:Response xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"
xmlns:dsig="http://www.w3.org/2000/09/xmldsig#"
xmlns:enc="http://www.w3.org/2001/04/xmlenc#"
xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"
xmlns:x500="urn:oasis:names:tc:SAML:2.0:profiles:attribute:X500"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
Destination="https://xxx/saml/post/ac"
ID="id-cefHM2F1RpCggtiERcLI-Z5AwyqM43zoVhtjSan0"
InResponseTo="_99a2e207-8b49-46ab-85a8-7448f32b34e9"
IssueInstant="2020-07-14T11:03:49Z"
Version="2.0"
>
<saml:Issuer Format="urn:oasis:names:tc:SAML:2.0:nameid-format:entity">https://yyy/oam/fed</saml:Issuer>
<dsig:Signature>
<dsig:SignedInfo>
<dsig:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
<dsig:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256" />
<dsig:Reference URI="#id-cefHM2F1RpCggtiERcLI-Z5AwyqM43zoVhtjSan0">
<dsig:Transforms>
<dsig:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
<dsig:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256" />
<dsig:DigestValue>/pQoLtuBTH/YNe4OKD4V6+qc2Rxf+na6pa8HonSRNeY=</dsig:DigestValue>
</dsig:Reference>
</dsig:SignedInfo>
<dsig:SignatureValue>WW5g8Kzh3XMvohJKsYKebvO...</dsig:SignatureValue>
<dsig:KeyInfo>
<dsig:X509Data>
<dsig:X509Certificate>MIIDUTCCAjmgAwIBAgIKTAxTewAAAAA...</dsig:X509Certificate>
</dsig:X509Data>
</dsig:KeyInfo>
</dsig:Signature>
<samlp:Status>
<samlp:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success" />
</samlp:Status>
<saml20:EncryptedAssertion xmlns:saml20="urn:oasis:names:tc:SAML:2.0:assertion">
<xenc:EncryptedData xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"
Id="id-a7DCb68sppndtm1EJHGc7tGXeaybYZqovq6DSXUP"
Type="http://www.w3.org/2001/04/xmlenc#Element"
>
<xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc" />
<KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
<dsig:RetrievalMethod Type="http://www.w3.org/2001/04/xmlenc#EncryptedKey"
URI="#id-OlT01t8FNBO2pIuB8ba-IlZ10dYXJEIgkMyiSOiZ"
/>
</KeyInfo>
<xenc:CipherData>
<xenc:CipherValue>WNCrzgQXVzhAJ61coe4qClUi8hyZVUQ8Z...</xenc:CipherValue>
</xenc:CipherData>
</xenc:EncryptedData>
<xenc:EncryptedKey xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"
Id="id-OlT01t8FNBO2pIuB8ba-IlZ10dYXJEIgkMyiSOiZ"
>
<xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5" />
<dsig:KeyInfo>
<dsig:X509Data>
<dsig:X509Certificate>MIIDNDCCAhygAwIBAgIQhNtIL...</dsig:X509Certificate>
</dsig:X509Data>
</dsig:KeyInfo>
<xenc:CipherData>
<xenc:CipherValue>R5usMrow6yS8ulpX0HApH/ExWk...</xenc:CipherValue>
</xenc:CipherData>
<xenc:ReferenceList>
<xenc:DataReference URI="#id-a7DCb68sppndtm1EJHGc7tGXeaybYZqovq6DSXUP" />
</xenc:ReferenceList>
</xenc:EncryptedKey>
</saml20:EncryptedAssertion>
</samlp:Response>
This SAML response is not correct SAML? Using library 1.2.2, the same SAML response was accepted. Why is it not accepted when using the 4.0.5 library?
Please help. Well thank you. DM