简体   繁体   English

如何从公钥字节数组创建 CX509PublicKey 对象

[英]How to create CX509PublicKey object from a public key byte array

I have created a RSA key pair, fetched the public key, cahnged it to byte array and sent it to another API for further flow.我创建了一个 RSA 密钥对,获取了公钥,将其转换为字节数组并将其发送到另一个 API 以进行进一步的流程。 There i need a CX509PublicKey to be generated from the received byte array.我需要从接收到的字节数组生成 CX509PublicKey。 How to do that?怎么做?

Following is the code以下是代码

RSACryptoServiceProvider RSA = new RSACryptoServiceProvider();
        var pk = RSA.ExportRSAPublicKey();
        return pk;

AND

CX509PublicKey cpk = new CX509PublicKey(pk);

        var objPkcs10 = new CX509CertificateRequestPkcs10();
        objPkcs10.InitializeFromPublicKeyTemplate(
            X509CertificateEnrollmentContext.ContextUser,
            pk, objPolicyServer,
            template);

The above code doesn't work!上面的代码不起作用! need to convert that pk to CX509PublicKey object.需要将该 pk 转换为 CX509PublicKey 对象。 Please Help!请帮忙!

PublicKey将例如 base64 作为输入。

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

相关问题 无法使用 CX509PublicKey::InitializeFromEncodedPublicKeyInfo 初始化公钥 object - Failing to initialize Public key object using CX509PublicKey::InitializeFromEncodedPublicKeyInfo 如何使用PublicKey.EncodedKeyValue.Format(true)从X509Store获取公共密钥 - how to get public key from X509Store using PublicKey.EncodedKeyValue.Format(true) C#如何从字节流中获取X509 PublicKey - C# How ro get X509 PublicKey from byte stream Bouncy Castle C# - 从字节数组中获取公钥对象 - Bouncy Castle C# - getting public key object from byte array C# 从 EC 公钥字节生成 PublicKey/IPublicKey 对象? - C# Generating PublicKey/IPublicKey object from EC Public key bytes? 从公钥字节数组重新创建椭圆曲线的 X 和 Y - Recreate X and Y of Elliptic curve from public key byte array 如何从 Azure Key Vault KeyBundle 创建 X509Certificate2 对象 - How can I create an X509Certificate2 object from an Azure Key Vault KeyBundle 如何从 PEM 格式的公钥创建证书 object? - How to create certificate object from public key in PEM format? 从 .cer 文件中获取公钥字节数组 - C# - Get Public Key byte array from .cer file - C# 如何使用(和创建)X509证书来进行JWT令牌的私钥/公钥加密 - How to work with (and create) X509 Certificates for private/public key encryption of JWT Tokens
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM