Skip to content

Latest commit

 

History

History
168 lines (138 loc) · 8.92 KB

nf-certenroll-ix509certificaterequestcertificate2-initializefromprivatekeytemplate.md

File metadata and controls

168 lines (138 loc) · 8.92 KB
UID title description helpviewer_keywords old-location tech.root ms.assetid ms.date ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames req.redist ms.custom f1_keywords dev_langs topic_type api_type api_location api_name
NF:certenroll.IX509CertificateRequestCertificate2.InitializeFromPrivateKeyTemplate
IX509CertificateRequestCertificate2::InitializeFromPrivateKeyTemplate (certenroll.h)
Initializes the certificate request by using an IX509PrivateKey object and a certificate template. (IX509CertificateRequestCertificate2.InitializeFromPrivateKeyTemplate)
ContextAdministratorForceMachine
ContextMachine
ContextUser
IX509CertificateRequestCertificate2 interface [Security]
InitializeFromPrivateKeyTemplate method
IX509CertificateRequestCertificate2.InitializeFromPrivateKeyTemplate
IX509CertificateRequestCertificate2::InitializeFromPrivateKeyTemplate
InitializeFromPrivateKeyTemplate
InitializeFromPrivateKeyTemplate method [Security]
InitializeFromPrivateKeyTemplate method [Security]
IX509CertificateRequestCertificate2 interface
certenroll/IX509CertificateRequestCertificate2::InitializeFromPrivateKeyTemplate
security.ix509certificaterequestcertificate2_initializefromprivatekeytemplate
security\ix509certificaterequestcertificate2_initializefromprivatekeytemplate.htm
security
334cc5f7-e74e-4f0b-b54b-6f1b121418da
12/05/2018
ContextAdministratorForceMachine, ContextMachine, ContextUser, IX509CertificateRequestCertificate2 interface [Security],InitializeFromPrivateKeyTemplate method, IX509CertificateRequestCertificate2.InitializeFromPrivateKeyTemplate, IX509CertificateRequestCertificate2::InitializeFromPrivateKeyTemplate, InitializeFromPrivateKeyTemplate, InitializeFromPrivateKeyTemplate method [Security], InitializeFromPrivateKeyTemplate method [Security],IX509CertificateRequestCertificate2 interface, certenroll/IX509CertificateRequestCertificate2::InitializeFromPrivateKeyTemplate, security.ix509certificaterequestcertificate2_initializefromprivatekeytemplate
certenroll.h
Windows
Windows 7 [desktop apps only]
Windows Server 2008 R2 [desktop apps only]
Certenroll.idl
Windows
19H1
IX509CertificateRequestCertificate2::InitializeFromPrivateKeyTemplate
certenroll/IX509CertificateRequestCertificate2::InitializeFromPrivateKeyTemplate
c++
APIRef
kbSyntax
COM
Certenroll.h
IX509CertificateRequestCertificate2.InitializeFromPrivateKeyTemplate

IX509CertificateRequestCertificate2::InitializeFromPrivateKeyTemplate

-description

The InitializeFromPrivateKeyTemplate method initializes the certificate request by using an IX509PrivateKey object and a certificate template.

-parameters

-param Context [in]

An X509CertificateEnrollmentContext enumeration value that specifies whether the requested certificate is intended for an end user, a computer, or an administrator acting on behalf of the computer. This can be one of the following values. However, if the MachineContext property of the private key is set, you must specify the ContextMachine enumeration value.

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.

-param pPrivateKey [in]

Pointer to an IX509PrivateKey interface that represents the private key.

-param pPolicyServer [in]

Pointer to an IX509EnrollmentPolicyServer object that represents the certificate enrollment policy (CEP) server that contains the template specified by the pTemplate parameter.

-param pTemplate [in]

Pointer to an IX509CertificateTemplate object that represents the template to use during initialization.

-returns

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
E_POINTER
The pPrivateKey, pPolicyServer, or pTemplate parameters are NULL.
HRESULT_FROM_WIN32(ERROR_ALREADY_INITIALIZED)
The certificate request object has already been initialized.

-remarks

The InitializeFromPrivateKeyTemplate method performs the following actions:

  • Adds the extensions specified by the template to an IX509Extensions collection.
  • Creates an IObjectIds collection and populates it with the default XCN_OID_KEY_USAGE and XCN_OID_BASIC_CONSTRAINTS2 object identifiers. If the template indicates that these OIDs are not critical, they are removed from the collection. The OIDs marked critical by the template are added.
  • Sets the SmimeCapabilities property if the template supports symmetric algorithms.
  • Sets the AlternateSignatureAlgorithm property if the template requires a discrete signature algorithm OID.
  • Creates an IX509SignatureInformation object.
  • Creates a hash algorithm OID if the algorithm is specified in the template and sets it on the IX509SignatureInformation object.
  • Retrieves an asymmetric encryption algorithm OID, if it exists, from the template and sets it on the IX509SignatureInformation object.
  • Populates many of the IX509PrivateKey properties from the template settings.

If the CSPInformations property is not specified, the method creates an ICspInformations collection from the providers installed on the computer.

No private key is created at this point. If the IX509PrivateKey object passed to the method does not represent an existing key, a key is created when the Encode method is called. The key will be created by using the default provider if no template was specified and the ProviderName property on the IX509PrivateKey is not set. When a private key exists, it is set on the PrivateKey property.

-see-also

IX509CertificateRequestCertificate2