SAMLSignatureException: Failed to generate XML signature. Invalid algorithm specified


We have upated to ComponentSpace.SAML2.dll version from older verion of

This upgrade broke our existing integration, because of :
“SAMLSignatureException: Failed to generate XML signature. Invalid algorithm specified”.

I seen you have covered the topic in forum posts:

We were generating self signed certificates for our integrations by code (not using openssl nor makecert), with Cryptographic Service Provider (CSP) set to “Microsoft Base Cryptographic Provider v1.0”, instead of “Microsoft Enhanced RSA and AES Cryptographic Provider”. We are using one of SHA256, SHA384 and SHA512 signature algorithms.

I have two questions:
• Why this was not an issue in version “”?
• Is there any way we can upgrade our already generated certificates to use correct CSP, and do not break existing integrations?

Thank you for the answers.

Best Regards

Prior to v2.6.0.13 we defaulted to SHA-1 signatures.
Later versions default to SHA-256 signatures although SHA-1 is still supported.

Upgrading your PFX file to the correct CSP should not affect other integrations.
The only change made to the PFX is a property that specifies which CSP to use.
The rest of the PFX, including the private key, remain unchanged.
You can still use the PFX to generate SHA-1 signatures if required.
Also, partner sites with your CER file can continue to use the same CER file.

Can you provide an C# example of how to set the CSP for existing X509Certificate2 ?


I don’t believe there’s a .NET framework API that supports updating the CSP.
You would have to call into the Windows API through PInvoke.
We don’t have any examples of this.

Do you have example with makecert or some other console application?

I suggest taking a look at our Certificate Guide.
The “Generating Self-Signed Certificates” section describes using PowerShell’s New-SelfSignedCertificate cmdlet to generate a self-signed certificate with the correct CSP for SHA-256 signature generation.

I found the following SO article which describes updating the CSP type in C#.

The EncryptedAssertion constructor defaults the symmetric key encryption method to “<a href=“””>" and the data encryption method to "<a href=“".">”.

What version of the SAML library are you using?

What version of the .NET framework are you using?

Have you tried the same code but specifying the “sp.cer” certificate that we include with the example projects? This will help identify whether the issue is related to your certificate.

If there’s still an issue, please enable SAML trace and send the generated log file as an email attachment to mentioning your forum post.