function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
PureFactsPureFacts 

m_safeCertContext is an invalid handle

I am working through the example

https://developer.salesforce.com/page/Configuring-SAML-SSO-to-Custom-.Net-Application

and the sample code is getting the exception 
 
m_SafeCertContext is an invalid handle

status = signedXml.CheckSignature(cert, true);

Googling this it seems the it may be related to an uninitialized field 

Anyone know how to address this.

Thanks in advance.

Whatty
 
PureFactsPureFacts
The actual exception we are getting is 

checking the signature failed!
System.Security.Cryptography.CryptographicException: m_safeCertContext is an invalid handle.
   at System.Security.Cryptography.X509Certificates.X509Certificate2.get_PublicKey()
   at System.Security.Cryptography.Xml.SignedXml.CheckSignature(X509Certificate2 certificate, Boolean verifySignatureOnly)
PureFactsPureFacts
Can anyone please provide some directions on where to start looking for a solution to this issue 
NagendraNagendra (Salesforce Developers) 
Hi PureFacts,

First and foremost sincerely regret for the delayed reply.

The error is thrown because no valid certificate is found.
This can be caused by either:
  • A problem with the cert. A common reason for this in a development environment is one of the cert properties differing from that of the environment eg cert common name does not match the site name.  I guess this would also occur if the cert had expired.
  • The cert did not get passed to the request.
For more details, please visit Error http://(m_safeCertContext is an invalid handle.) when accessing a client certificate using .NET 2.0/VS2005, also check out here for another discussion about this issue.

For more information on similar issue please check here:
Mark this as solved if it's resolved.

Best Regards,
Nagendra.P