RSACertificateExtensions.CopyWithPrivateKey(X509Certificate2, RSA) 方法

定义

将私钥与 RSA 证书的公钥合并,以生成新的 RSA 证书。

public:
[System::Runtime::CompilerServices::Extension]
 static System::Security::Cryptography::X509Certificates::X509Certificate2 ^ CopyWithPrivateKey(System::Security::Cryptography::X509Certificates::X509Certificate2 ^ certificate, System::Security::Cryptography::RSA ^ privateKey);
public static System.Security.Cryptography.X509Certificates.X509Certificate2 CopyWithPrivateKey (this System.Security.Cryptography.X509Certificates.X509Certificate2 certificate, System.Security.Cryptography.RSA privateKey);
static member CopyWithPrivateKey : System.Security.Cryptography.X509Certificates.X509Certificate2 * System.Security.Cryptography.RSA -> System.Security.Cryptography.X509Certificates.X509Certificate2
<Extension()>
Public Function CopyWithPrivateKey (certificate As X509Certificate2, privateKey As RSA) As X509Certificate2

参数

certificate
X509Certificate2

RSA 证书。

privateKey
RSA

私有 RSA 密钥。

返回

新 RSA 证书,其 HasPrivateKey 属性设置为 true。 未修改输入 RSA 证书对象。

例外

certificateprivateKeynull

该证书已有关联的私钥。

该证书没有公钥。

- 或 -

指定私钥与指定证书的公钥不匹配。

适用于