Certificate object

[CAPICOM is a 32-bit only component that is available for use in the following operating systems: Windows Server 2008, Windows Vista, and Windows XP. Instead, use the X509Certificate2 Class in the System.Security.Cryptography.X509Certificates namespace.]

The Certificate object represents a single digital certificate.

The Certificate object exposes the following interfaces:

  • ICertificate — Introduced in CAPICOM 1.0.
  • ICertificate2 — Introduced in CAPICOM 2.0.

When to use

The Certificate object is used to perform the following tasks:

  • Load certificate data, including the private key, from a file.
  • Get information from the certificate.
  • Return basic constraints, EKU, extended properties, extensions, key usage, public key, and template objects associated with the certificate.
  • Determine whether the certificate is valid and check the access availability of the certificate subject's private key.
  • Display the certificate.
  • Import and export the certificate.
  • Save the certificate to a file.
  • Retrieve or set properties that describe the certificate.

Members

The Certificate object has these types of members:

Methods

The Certificate object has these methods.

Method Description
BasicConstraints Returns a BasicConstraints object that represents the basic constraints extension of the certificate.
(Inherited from CertificateICertificate2ICertificate)
Display Displays a certificate.
(Inherited from CertificateICertificate2ICertificate)
Export Copies a certificate to an encoded string. The encoded string can be written to a file or imported into a new Certificate object.
(Inherited from CertificateICertificate2ICertificate)
ExtendedKeyUsage Returns an ExtendedKeyUsage object that indicates the valid extended key uses of the certificate.
(Inherited from CertificateICertificate2ICertificate)
ExtendedProperties Returns a collection of the extended properties of the certificate.
(Inherited from CertificateICertificate2)
Extensions Returns a collection of the extensions associated with the certificate.
(Inherited from CertificateICertificate2)
GetInfo Retrieves information from the certificate.
(Inherited from CertificateICertificate2ICertificate)
HasPrivateKey Determines whether the certificate has a private key associated with it.
(Inherited from CertificateICertificate2ICertificate)
Import Imports a previously encoded certificate from a string into the Certificate object.
(Inherited from CertificateICertificate2ICertificate)
IsValid Builds a certificate verification chain for a certificate and returns a CertificateStatus object that contains the validity status of the certificate.
(Inherited from CertificateICertificate2ICertificate)
KeyUsage Returns a KeyUsage object that indicates the valid key usage of the certificate.
(Inherited from CertificateICertificate2ICertificate)
Load Imports a certificate from a file.
(Inherited from CertificateICertificate2)
PublicKey Returns a PublicKey object.
(Inherited from CertificateICertificate2)
Save Saves the certificate to a file.
(Inherited from CertificateICertificate2)
Template Returns the template associated with the certificate.
(Inherited from CertificateICertificate2)

 

Properties

The Certificate object has these properties.

Property Access type Description
Archived
Read/write
Sets or retrieves a Boolean value that indicates whether the certificate is archived.
(Inherited from CertificateICertificate2)
IssuerName
Read-only
Retrieves a string that contains the name of the certificate issuer.
(Inherited from CertificateICertificate2ICertificate)
PrivateKey
Read/write
Sets or retrieves the private key associated with the certificate.
(Inherited from CertificateICertificate2)
SerialNumber
Read-only
Retrieves a string that contains the certificate serial number.
(Inherited from CertificateICertificate2ICertificate)
SubjectName
Read-only
Retrieves a string that contains the name of the certificate subject.
(Inherited from CertificateICertificate2ICertificate)
Thumbprint
Read-only
Retrieves a hexadecimal string that contains the SHA-1 hash of the certificate.
(Inherited from CertificateICertificate2ICertificate)
ValidFromDate
Read-only
Retrieves the beginning date for the validity of the certificate.
(Inherited from CertificateICertificate2ICertificate)
ValidToDate
Read-only
Retrieves the ending date for the validity of the certificate.
(Inherited from CertificateICertificate2ICertificate)
Version
Read-only
Retrieves the version number of the certificate.
(Inherited from CertificateICertificate2ICertificate)

 

Remarks

The Certificate object can be created, and it is safe for scripting. The ProgID for the Certificate object is "CAPICOM.Certificate.2".

CAPICOM 1.x: The ProgID for the Certificate object is "CAPICOM.Certificate.1".

Requirements

Requirement Value
End of client support
Windows Vista
End of server support
Windows Server 2008
Redistributable
CAPICOM 2.0 or later on Windows Server 2003 and Windows XP
DLL
Capicom.dll