繁体   English   中英

在C#中使用X509Certificate(SalesForce证书)在xml文档上签名时出现错误,以进行单点登录SAML帖子

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

我正在尝试使用SAML POST Single Sign-On到SalesForce。 我已经创建了SalesForce沙箱帐户, Certificate and Key ManagementCertificate and Key Management下载了Certificate 我在C#代码中使用了该Certificate ,但是它给出了错误Signing key is not loaded. 在下面的代码

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

在调试时,我发现它在创建证书实例时如下

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

实例已创建,但属性certificate.PrivateKey仍为null,原因可能是它给出了错误Signing key is not loaded.

任何想法如何使用证书创建签名?

经过大量的研发,我了解了C#代码

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

需要证书的私钥文件,而我尝试使用公钥文件。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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