IX509CertificateRequestCmc::InitializeFromInnerRequestTemplateName method (certenroll.h)

The InitializeFromInnerRequestTemplateName method initializes the certificate request from an inner request object and a template.

Syntax

HRESULT InitializeFromInnerRequestTemplateName(
  [in] IX509CertificateRequest *pInnerRequest,
  [in] BSTR                    strTemplateName
);

Parameters

[in] pInnerRequest

Pointer to an IX509CertificateRequest interface that represents the inner request object. This can be a PKCS #10 or a CMC request.

[in] strTemplateName

A BSTR variable that contains the Common Name (CN) of the template as it appears in Active Directory or the dotted decimal object identifier.

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/value Description
CRYPT_E_INVALID_MSG_TYPE
The request object passed to the pInnerRequest parameter must be a PKCS #10 or a CMC request.
HRESULT_FROM_WIN32(ERROR_ALREADY_INITIALIZED)
The request object has already been initialized.

Remarks

By specifying a template, you can add information to the outer request object that may not be contained in the inner request. For example, if the inner request does not contain the necessary extensions, you can supply a template that does.

The InitializeFromInnerRequestTemplateName method:

  • Creates an empty ICryptAttributes collection.
  • Creates an empty IX509NameValuePairs collection.
  • Creates an empty IX509Extensions collection.
  • Creates an IObjectIds collection for critical extensions and adds the XCN_OID_KEY_USAGE and XCN_OID_BASIC_CONSTRAINTS2 object identifiers (OIDs).
  • Creates an empty IObjectIds collection of OIDs to be suppressed from the request object.
  • Creates an empty ISignerCertificates collection.
  • Retrieves private key flags from the template.
  • Sets the ArchivePrivateKey property if required by the template flags or settings.
  • Retrieves the encryption algorithm from the template if one is specified and sets the EncryptionAlgorithm property.
  • Sets the EncryptionStrength property if possible.

Requirements

Requirement Value
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

IX509CertificateRequestCmc