我正在尝试使用公钥对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;