I have to validate two SAML 2.0 assertion signatures. I can parse out all the key and token parameters and now want to use the .NET CryptoUtils.VerifySignature() or some other function to validate the signatures. I have the text that was signed and the signature as a byte[] array as well as the hash OID. I have the RSA and SAML token parameters such as the Signature Value, modulus, exponent, etc. What I’m missing is the x509 cert to send into the .NET VerifySignature() routine. I can’t see how to create the cert programmatically from the parameters.
I’d also appreciate any suggestions on a library, c# and Java, that will handle creating, parsing, validating SAML 2.0 tokens (requests and responses).
In C#, you can use…
System.Security.Cryptography.Xml.SignedXml.CheckSignature(System.Security.Cryptography.X509Certificates.X509Certificate2 certificate, bool verifySignatureOnly)…to validate the signature. Basically, it would work like this: