IX509CertificateRequest::Initialize method (certenroll.h)

The Initialize method initializes the request object for a user or a computer.

Syntax

HRESULT Initialize(
  X509CertificateEnrollmentContext Context
);

Parameters

Context

An X509CertificateEnrollmentContext enumeration value that specifies whether the certificate is intended for an end user, a computer, or an administrator acting on behalf of a computer. This can be one of the following values.

Value Meaning
ContextUser
The certificate is being requested for an end user.
ContextMachine
The certificate is being requested for a computer.
ContextAdministratorForceMachine
The certificate is being requested by an administrator acting on the behalf of a computer.

Return value

If the function succeeds, the function returns S_OK.

If the function fails, it returns an HRESULT value that indicates the error. Possible values include, but are not limited to, those in the following table. For a list of common error codes, see Common HRESULT Values.

Return code Description
HRESULT_FROM_WIN32(ERROR_ALREADY_INITIALIZED)
The object is already initialized.

Remarks

The Initialize method initializes various objects depending on the type of certificate request being created. If you call this method from an IX509CertificateRequestPkcs10 object, a private key object is created and the following objects are initialized:

  • An empty ICryptAttributes collection.
  • An empty IX509Extensions collection.
  • An IObjectIds collection that contains the default critical extension object identifiers, XCN_OID_KEY_USAGE and XCN_OID_BASIC_CONSTRAINTS2. This collection can be retrieved by calling the CriticalExtensions property.
  • An empty IObjectIds collection for the SuppressOids property.
  • An ICspInformations object that contains the values you specified in the CSPInformations property or a collection of all providers installed on the computer. This collection is used to create a private key.

If you call this method from an IX509CertificateRequestCmc object, an inner PKCS #10 request is created as above and the following objects are initialized:

If you call this method from an IX509CertificateRequestPkcs7 object, an inner PKCS #10 request is created as above.

The following properties can be called before you call this method.

You must call the CSPInformations property before calling this method if you want to specify an ICspInformations collection.

Requirements

   
Minimum supported client Windows Vista [desktop apps only]
Minimum supported server Windows Server 2008 [desktop apps only]
Target Platform Windows
Header certenroll.h
DLL CertEnroll.dll

See also

IX509CertificateRequest

IX509CertificateRequestCertificate

IX509CertificateRequestCmc

IX509CertificateRequestPkcs10

IX509CertificateRequestPkcs7

IX509SignatureInformation