简体   繁体   中英

Getting error while signing xml document with X509Certificate(SalesForce certificate) in C# for Single Sign-On SAML post

I am trying to Single Sign-On with SAML POST to SalesForce. I have created SalesForce sandbox account, downloaded Certificate from Certificate and Key Management . I am using that Certificate in my C# code but it gives error Signing key is not loaded. at following code

 XmlElement signature = SigningHelper.SignDoc(xmlDocument, certificate, "ID", refValue);

While my debugging I found when it creates certificate instance as following

certificate = new X509Certificate2("d:/certificate.crt", "testpassword", X509KeyStorageFlags.Exportable);

instance is created but property certificate.PrivateKey remains null due to may be it is giving error Signing key is not loaded.

Any idea how to create signature with certificate?

After a lot of R&D I got to know c# code

XmlElement signature = SigningHelper.SignDoc(xmlDocument, certificate, "ID", refValue);

requires private key file of certification whereas I was trying with public key file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM