在C#中使用X509Certificate(SalesForce证书)为Single Sign-On SAML帖子签名x

本文关键字:SAML Sign-On Single X509Certificate 证书 SalesForce | 更新日期: 2023-09-27 18:21:36

我正在尝试将Single Sign-OnSAML POST一起发送到SalesForce。我已经创建了SalesForce沙箱帐户,从Certificate 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保持为空,原因可能是它给出了错误Signing key is not loaded.

知道如何用证书创建签名吗?

在C#中使用X509Certificate(SalesForce证书)为Single Sign-On SAML帖子签名x

经过大量的R&D我了解了c#代码

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

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