0

我正在尝试使用公钥签署 XML。我正在从 SP 提供的 base64 字符串加载证书。证书加载正常,公钥似乎有信息,但是当我尝试使用它时,出现以下错误:

键集不存在

这是实际的代码......有什么建议吗?非常感谢!

var signingCertificateX509 = new System.Security.Cryptography.X509Certificates.X509Certificate2(Convert.FromBase64String(base64EncryptingCertificate), "password", X509KeyStorageFlags.PersistKeySet);

        SignedXml signedXml = new SignedXml(doc);
        signedXml.SignedInfo.CanonicalizationMethod = SignedXml.XmlDsigExcC14NTransformUrl;
        signedXml.SignedInfo.SignatureMethod = "http://www.w3.org/2000/09/xmldsig#rsa-sha1";
        signedXml.SigningKey = signingCertificateX509.PublicKey.Key;
4

0 回答 0