System.Security.Cryptography.X509Certificates.X509Certificate2.PrivateKey Property

Gets or sets the System.Security.Cryptography.AsymmetricAlgorithm object that represents the private key associated with a certificate.

Syntax

public System.Security.Cryptography.AsymmetricAlgorithm PrivateKey { get; set; }

Value

Documentation for this section has not yet been entered.

Remarks

Currently this property supports only RSA or DSA keys, so it returns either an System.Security.Cryptography.RSACryptoServiceProvider or a System.Security.Cryptography.DSACryptoServiceProvider object. If no private key is associated with the certificate, it returns null.

Note:

If you set this property to null or to another key without first deleting it, a private key file is left on the disk.

To properly delete the private key associated with this property, set PersistKeyInCsp to false, and then call the System.Security.Cryptography.AsymmetricAlgorithm.Clear method.

Requirements

Namespace: System.Security.Cryptography.X509Certificates
Assembly: System (in System.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0
Since: .NET 2.0