ECDsaCertificateExtensions.CopyWithPrivateKey(X509Certificate2, ECDsa) 方法

定義

結合私密金鑰與 ECDsa 憑證的公開金鑰,以產生新的 ECDSA 憑證。Combines a private key with the public key of an ECDsa certificate to generate a new ECDSA certificate.

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

參數

certificate
X509Certificate2

ECDSA 憑證。The ECDSA certificate.

privateKey
ECDsa

私密 ECDSA 金鑰。The private ECDSA key.

傳回

X509Certificate2

HasPrivateKey 屬性設為 true 的新 ECDSA 憑證。A new ECDSA certificate with the HasPrivateKey property set to true. 輸入 ECDSA 憑證物件未修改。The input ECDSA certificate object isn't modified.

例外狀況

certificateprivateKeynullcertificate or privateKey is null.

憑證已有相關的私密金鑰。The certificate already has an associated private key.

憑證沒有公開金鑰。The certificate doesn't have a public key.

-或--or-

指定的私密金鑰與指定憑證的公開金鑰不相符。The specified private key doesn't match the public key for the specified certificate.

適用於