語言

X509Certificate2.CopyWithPrivateKey 方法

定義

將私鑰與包含相關公鑰的憑證合併成一個新的實例,該實例可存取該私鑰。

多載

名稱 Description
CopyWithPrivateKey(CompositeMLDsa)

將私鑰與包含相關公鑰的憑證合併成一個新的實例,該實例可存取該私鑰。

CopyWithPrivateKey(CompositeMLKem)
CopyWithPrivateKey(ECDiffieHellman)

將私鑰與證書的 ECDiffieHellman 公鑰結合,產生新的 ECDiffieHellman 證書。

CopyWithPrivateKey(MLDsa)

將私鑰與包含相關公鑰的憑證合併成一個新的實例,該實例可存取該私鑰。

CopyWithPrivateKey(MLKem)

將私鑰與包含相關公鑰的憑證合併成一個新的實例,該實例可存取該私鑰。

CopyWithPrivateKey(SlhDsa)

將私鑰與包含相關公鑰的憑證合併成一個新的實例,該實例可存取該私鑰。

CopyWithPrivateKey(CompositeMLDsa)

來源:
X509Certificate2.cs
來源:
X509Certificate2.cs

將私鑰與包含相關公鑰的憑證合併成一個新的實例,該實例可存取該私鑰。

public:
 System::Security::Cryptography::X509Certificates::X509Certificate2 ^ CopyWithPrivateKey(System::Security::Cryptography::CompositeMLDsa ^ privateKey);
[System.Diagnostics.CodeAnalysis.Experimental("SYSLIB5006", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public System.Security.Cryptography.X509Certificates.X509Certificate2 CopyWithPrivateKey(System.Security.Cryptography.CompositeMLDsa privateKey);
[<System.Diagnostics.CodeAnalysis.Experimental("SYSLIB5006", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
member this.CopyWithPrivateKey : System.Security.Cryptography.CompositeMLDsa -> System.Security.Cryptography.X509Certificates.X509Certificate2
Public Function CopyWithPrivateKey (privateKey As CompositeMLDsa) As X509Certificate2

參數

privateKey
CompositeMLDsa

複合金鑰 ML-DSA 對應於此憑證中 ML-DSA 公鑰的複合金鑰。

傳回

一張新的憑證,屬性 HasPrivateKey 設定為 true。

目前的證書沒有被修改。

屬性

例外狀況

privateKey 是 null。

指定的私鑰與此憑證的公鑰不符。

憑證本身已經有一個對應的私鑰。

此平台不支援結合憑證與複合 ML-DSA 私鑰。

適用於

CopyWithPrivateKey(CompositeMLKem)

來源:
X509Certificate2.cs
public:
 System::Security::Cryptography::X509Certificates::X509Certificate2 ^ CopyWithPrivateKey(System::Security::Cryptography::CompositeMLKem ^ privateKey);
[System.Diagnostics.CodeAnalysis.Experimental("SYSLIB5006", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public System.Security.Cryptography.X509Certificates.X509Certificate2 CopyWithPrivateKey(System.Security.Cryptography.CompositeMLKem privateKey);
[<System.Diagnostics.CodeAnalysis.Experimental("SYSLIB5006", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
member this.CopyWithPrivateKey : System.Security.Cryptography.CompositeMLKem -> System.Security.Cryptography.X509Certificates.X509Certificate2
Public Function CopyWithPrivateKey (privateKey As CompositeMLKem) As X509Certificate2

參數

privateKey
CompositeMLKem

傳回

屬性

適用於

CopyWithPrivateKey(ECDiffieHellman)

來源:
X509Certificate2.cs
來源:
X509Certificate2.cs
來源:
X509Certificate2.cs
來源:
X509Certificate2.cs
來源:
X509Certificate2.cs

將私鑰與證書的 ECDiffieHellman 公鑰結合,產生新的 ECDiffieHellman 證書。

public:
 System::Security::Cryptography::X509Certificates::X509Certificate2 ^ CopyWithPrivateKey(System::Security::Cryptography::ECDiffieHellman ^ privateKey);
public System.Security.Cryptography.X509Certificates.X509Certificate2 CopyWithPrivateKey(System.Security.Cryptography.ECDiffieHellman privateKey);
member this.CopyWithPrivateKey : System.Security.Cryptography.ECDiffieHellman -> System.Security.Cryptography.X509Certificates.X509Certificate2
Public Function CopyWithPrivateKey (privateKey As ECDiffieHellman) As X509Certificate2

參數

privateKey
ECDiffieHellman

私人ECDiffieHellman密鑰。

傳回

一份新的 ECDiffieHellman 證書,屬性 HasPrivateKey 設定為 true。 目前的證書沒有被修改。

例外狀況

privateKey 是 null。

憑證本身已經有一個對應的私鑰。

憑證沒有公開金鑰。

-或-

指定的私鑰與此憑證的公鑰不符。

適用於

CopyWithPrivateKey(MLDsa)

來源:
X509Certificate2.cs
來源:
X509Certificate2.cs

將私鑰與包含相關公鑰的憑證合併成一個新的實例,該實例可存取該私鑰。

public:
 System::Security::Cryptography::X509Certificates::X509Certificate2 ^ CopyWithPrivateKey(System::Security::Cryptography::MLDsa ^ privateKey);
[System.Diagnostics.CodeAnalysis.Experimental("SYSLIB5006", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public System.Security.Cryptography.X509Certificates.X509Certificate2 CopyWithPrivateKey(System.Security.Cryptography.MLDsa privateKey);
public System.Security.Cryptography.X509Certificates.X509Certificate2 CopyWithPrivateKey(System.Security.Cryptography.MLDsa privateKey);
[<System.Diagnostics.CodeAnalysis.Experimental("SYSLIB5006", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
member this.CopyWithPrivateKey : System.Security.Cryptography.MLDsa -> System.Security.Cryptography.X509Certificates.X509Certificate2
member this.CopyWithPrivateKey : System.Security.Cryptography.MLDsa -> System.Security.Cryptography.X509Certificates.X509Certificate2
Public Function CopyWithPrivateKey (privateKey As MLDsa) As X509Certificate2

參數

privateKey
MLDsa

ML-DSA 私密金鑰,對應於此憑證中 ML-DSA 公鑰。

傳回

一張新的憑證,屬性 HasPrivateKey 設定為 true。

目前的證書沒有被修改。

屬性

例外狀況

privateKey 是 null。

指定的私鑰與此憑證的公鑰不符。

憑證本身已經有一個對應的私鑰。

適用於

CopyWithPrivateKey(MLKem)

來源:
X509Certificate2.cs
來源:
X509Certificate2.cs

將私鑰與包含相關公鑰的憑證合併成一個新的實例,該實例可存取該私鑰。

public:
 System::Security::Cryptography::X509Certificates::X509Certificate2 ^ CopyWithPrivateKey(System::Security::Cryptography::MLKem ^ privateKey);
[System.Diagnostics.CodeAnalysis.Experimental("SYSLIB5006", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public System.Security.Cryptography.X509Certificates.X509Certificate2 CopyWithPrivateKey(System.Security.Cryptography.MLKem privateKey);
public System.Security.Cryptography.X509Certificates.X509Certificate2 CopyWithPrivateKey(System.Security.Cryptography.MLKem privateKey);
[<System.Diagnostics.CodeAnalysis.Experimental("SYSLIB5006", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
member this.CopyWithPrivateKey : System.Security.Cryptography.MLKem -> System.Security.Cryptography.X509Certificates.X509Certificate2
member this.CopyWithPrivateKey : System.Security.Cryptography.MLKem -> System.Security.Cryptography.X509Certificates.X509Certificate2
Public Function CopyWithPrivateKey (privateKey As MLKem) As X509Certificate2

參數

privateKey
MLKem

ML-KEM 私密金鑰,對應於此憑證中 ML-KEM 公鑰。

傳回

一張新的憑證,屬性 HasPrivateKey 設定為 true。

目前的證書沒有被修改。

屬性

例外狀況

privateKey 是 null。

指定的私鑰與此憑證的公鑰不符。

憑證本身已經有一個對應的私鑰。

適用於

CopyWithPrivateKey(SlhDsa)

來源:
X509Certificate2.cs
來源:
X509Certificate2.cs

將私鑰與包含相關公鑰的憑證合併成一個新的實例,該實例可存取該私鑰。

public:
 System::Security::Cryptography::X509Certificates::X509Certificate2 ^ CopyWithPrivateKey(System::Security::Cryptography::SlhDsa ^ privateKey);
[System.Diagnostics.CodeAnalysis.Experimental("SYSLIB5006", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public System.Security.Cryptography.X509Certificates.X509Certificate2 CopyWithPrivateKey(System.Security.Cryptography.SlhDsa privateKey);
[<System.Diagnostics.CodeAnalysis.Experimental("SYSLIB5006", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
member this.CopyWithPrivateKey : System.Security.Cryptography.SlhDsa -> System.Security.Cryptography.X509Certificates.X509Certificate2
Public Function CopyWithPrivateKey (privateKey As SlhDsa) As X509Certificate2

參數

privateKey
SlhDsa

SLH-DSA 私密金鑰,對應於此憑證中 SLH-DSA 公鑰。

傳回

一張新的憑證,屬性 HasPrivateKey 設定為 true。

目前的證書沒有被修改。

屬性

例外狀況

privateKey 是 null。

指定的私鑰與此憑證的公鑰不符。

憑證本身已經有一個對應的私鑰。

適用於