Search code examples
c#.net.net-5

SignedXml.CheckSIgnature NullReferenceException after updating System.Security.Cryptography.Xml from 4.7.0 to 5.0.0


After updating System.Security.Cryptography.Xml from 4.7.0 to 5.0.0 or 6.0.0, with no other changes to my code, I'm getting a NullReferenceException in IsKeyTheCorrectAlgorithm. The certificates being used are SHA1 and SHA256 self-signed certificates, created using CNG, CAPI, and OpenSSL.


Solution

  • After weeks of searching, I finally found this obscure GitHub issue indicating the solution (but without acknowledging a problem or fixing the issue): https://github.com/dotnet/runtime/issues/55383.

    The solution is to remove calls to CryptoConfig.AddAlgorithm, which is apparently no longer needed.