Edit

Share via


X509CertificateKeyAccessors.CopyWithPrivateKey Method

Definition

Overloads

CopyWithPrivateKey(X509Certificate2, CompositeMLDsa)

Combines a private key with a certificate containing the associated public key into a new instance that can access the private key.

CopyWithPrivateKey(X509Certificate2, MLDsa)

Combines a private key with a certificate containing the associated public key into a new instance that can access the private key.

CopyWithPrivateKey(X509Certificate2, MLKem)

Combines a private key with a certificate containing the associated public key into a new instance that can access the private key.

CopyWithPrivateKey(X509Certificate2, SlhDsa)

Combines a private key with a certificate containing the associated public key into a new instance that can access the private key.

CopyWithPrivateKey(X509Certificate2, CompositeMLDsa)

Source:
X509CertificateKeyAccessors.cs
Source:
X509CertificateKeyAccessors.cs

Combines a private key with a certificate containing the associated public key into a new instance that can access the private key.

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

Parameters

certificate
X509Certificate2

The X.509 certificate that contains the public key.

privateKey
CompositeMLDsa

The Composite ML-DSA private key that corresponds to the Composite ML-DSA public key in this certificate.

Returns

A new certificate with the HasPrivateKey property set to true.

The current certificate isn't modified.

Attributes

Exceptions

certificate or privateKey is null.

The specified private key doesn't match the public key for this certificate.

The certificate already has an associated private key.

Combining a certificate and a Composite ML-DSA private key is not supported on this platform.

Applies to

CopyWithPrivateKey(X509Certificate2, MLDsa)

Source:
X509CertificateKeyAccessors.cs
Source:
X509CertificateKeyAccessors.cs

Combines a private key with a certificate containing the associated public key into a new instance that can access the private key.

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

Parameters

certificate
X509Certificate2

The X.509 certificate that contains the public key.

privateKey
MLDsa

The ML-DSA private key that corresponds to the ML-DSA public key in this certificate.

Returns

A new certificate with the HasPrivateKey property set to true.

The current certificate isn't modified.

Attributes

Exceptions

certificate or privateKey is null.

The specified private key doesn't match the public key for this certificate.

The certificate already has an associated private key.

Combining a certificate and an ML-DSA private key is not supported on this platform.

Applies to

CopyWithPrivateKey(X509Certificate2, MLKem)

Source:
X509CertificateKeyAccessors.cs
Source:
X509CertificateKeyAccessors.cs

Combines a private key with a certificate containing the associated public key into a new instance that can access the private key.

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

Parameters

certificate
X509Certificate2

The X.509 certificate that contains the public key.

privateKey
MLKem

The ML-KEM private key that corresponds to the ML-KEM public key in this certificate.

Returns

A new certificate with the HasPrivateKey property set to true.

The current certificate isn't modified.

Attributes

Exceptions

certificate or privateKey is null.

The specified private key doesn't match the public key for this certificate.

The certificate already has an associated private key.

Combining a certificate and an ML-KEM private key is not supported on this platform.

Applies to

CopyWithPrivateKey(X509Certificate2, SlhDsa)

Source:
X509CertificateKeyAccessors.cs
Source:
X509CertificateKeyAccessors.cs

Combines a private key with a certificate containing the associated public key into a new instance that can access the private key.

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

Parameters

certificate
X509Certificate2

The X509 certificate that contains the public key.

privateKey
SlhDsa

The SLH-DSA private key that corresponds to the SLH-DSA public key in this certificate.

Returns

A new certificate with the HasPrivateKey property set to true.

The current certificate isn't modified.

Attributes

Exceptions

certificate or privateKey is null.

The specified private key doesn't match the public key for this certificate.

The certificate already has an associated private key.

Combining a certificate and an SLH-DSA private key is not supported on this platform.

Applies to