jitbit / AspNetSaml

Very simple SAML 2.0 consumer module for ASP.NET/C#

Home Page:https://www.jitbit.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SignatureDescription could not be created for the signature algorithm supplied

CalvinPangch opened this issue · comments

I could get the SAML response,

when hit the code samlResponse.IsValid(), then i got the error message as below :

SignatureDescription could not be created for the signature algorithm suppliedSystem.Security.Cryptography.CryptographicException: SignatureDescription could not be created for the signature algorithm supplied.
at System.Security.Cryptography.Xml.SignedXml.CheckSignedInfo(AsymmetricAlgorithm key)
at System.Security.Cryptography.Xml.SignedXml.CheckSignature(AsymmetricAlgorithm key)
at System.Security.Cryptography.Xml.SignedXml.CheckSignature(X509Certificate2 certificate, Boolean verifySignatureOnly)
at Testing.Security.SAML.SSOSignIn.Response.IsValid()

could you please help.
Thank you.

Which .NET version you're on?

.NetFramework 4.5.2

I had comment the code signedXml.CheckSignature(_certificate, true) and its work as expected .

do we really need the checkSignature ? what will happen if we don't checkSignature ?

  1. Please consider upgrading to 4.7.2 or later
  2. Yes you do need it otherwise how do you verify that the response is really from the real provider, not a MITM attacker

I had solved the issue. just add this line.
CryptoConfig.AddAlgorithm(typeof(RSAPKCS1SHA256SignatureDescription), "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256");

the solution can be found in below links :
https://stackoverflow.com/questions/16728558/signed-xml-signature-verification-for-sso-saml-using-sha256

Thank you.