【发布时间】:2020-06-17 11:08:53
【问题描述】:
我创建了一个 RSA 密钥对,获取了公钥,将其转换为字节数组并将其发送到另一个 API 以进行进一步处理。我需要从接收到的字节数组生成一个 CX509PublicKey。该怎么做?
下面是代码
RSACryptoServiceProvider RSA = new RSACryptoServiceProvider();
var pk = RSA.ExportRSAPublicKey();
return pk;
与
CX509PublicKey cpk = new CX509PublicKey(pk);
var objPkcs10 = new CX509CertificateRequestPkcs10();
objPkcs10.InitializeFromPublicKeyTemplate(
X509CertificateEnrollmentContext.ContextUser,
pk, objPolicyServer,
template);
上面的代码不起作用!需要将该 pk 转换为 CX509PublicKey 对象。请帮忙!
【问题讨论】:
-
您可能需要将 PKCS#1 格式的公钥转换为 SubjectPublicKeyInfo。我没有太多时间弄清楚如何执行此操作,但这应该会给您一些搜索提示。
标签: c# cryptography certificate key rsa