PrivateKey object

[The PrivateKey object is available for use in the operating systems specified in the Requirements section. Instead, use the X509Certificate2.PrivateKey Property in the System.Security.Cryptography.X509Certificates namespace.]

The PrivateKey object represents the private key associated with a certificate.

When to use

The PrivateKey object is used to perform the following tasks:

  • Retrieve information about the private key.
  • Open the private key container.
  • Delete the private key.

Members

The PrivateKey object has these types of members:

Methods

The PrivateKey object has these methods.

Method Description
Delete Deletes the private key container referenced by the PrivateKey object.
IsAccessible Retrieves a Boolean value that indicates whether the private key is accessible by the user. If true, the user can access the private key.
IsExportable Retrieves a Boolean value that indicates whether the private key can be exported. If true, the private key can be exported.
IsHardwareDevice Retrieves a Boolean value that indicates whether the private key is stored on a hardware device. If true, the private key is stored on a hardware device.
IsMachineKeyset Retrieves a Boolean value that indicates whether the private key is a machine key. If true, the private key is a machine key.
IsProtected Retrieves a Boolean value that indicates whether the private key is protected. If true, the private key is protected.
IsRemovable Retrieves a Boolean value that indicates whether the private key is on a removable device. If true, the private key is on a removable device.
Open Accesses an existing key container.

 

Properties

The PrivateKey object has these properties.

Property Access type Description
ContainerName
Read-only
Retrieves a string that contains the private key container name. This is the default property.
KeySpec
Read-only
Retrieves the key specification.
ProviderName
Read-only
Retrieves a string that contains the name of the CSP.
ProviderType
Read-only
Retrieves an enumeration value that specifies the type of provider.
UniqueContainerName
Read-only
Retrieves a string that contains the unique private key container name.

 

Remarks

The PrivateKey object can be created, and it is safe for scripting. The ProgID for the PrivateKey object is CAPICOM.PrivateKey.1.

Requirements

Requirement Value
Redistributable
CAPICOM 2.0 or later on Windows Server 2003 and Windows XP
DLL
Capicom.dll