enrollCommon

The enrollCommon folder contains the following helper functions and macros used by the samples provided with the Certificate Enrollment SDK. It is installed by default in the %ProgramFiles%\Microsoft SDKs\Windows\v7.0\Samples\Security\X509 Certificate Enrollment\VC\enrollCommon folder.

Function Description
_JumpIfError Macro that accepts an HRESULT value, a label, and an error string, prints the string, and transfers program control to the first statement following the label.
_JumpError Same as the _JumpIfError macro.
_PrintIfError Not currently used.
_PrintError Macro that prints an error message and an HRESULT value.
convertWszToSz Converts a wide-character string to an ASCII character string by using the WideCharToMultiByte function and the current ANSI code-page identifier for the system. This function is used by the decConvertFromUnicode and findOIDFromTemplateName functions defined in enrollCommon.cpp.
convertSzToWsz Converts an ASCII string to a wide-character string by using the MultiByteToWideChar function and the current ANSI code-page identifier for the system. This function is used by the findCertByTemplate function defined in enrollCommon.cpp.
convertSzToBstr Converts an ASCII string to a BSTR by using the MultiByteToWideChar function. This function is not currently used.
convertWszToBstr Converts a wide-character string to a BSTR. This function is used by the installResponseFromPFX sample.
checkEnrollStatus Checks the status of the certificate enrollment process by using the IX509Enrollment and IX509EnrollmentStatus interfaces. This function is used by the enrollEOBOCMC, enrollPKCS7, enrollRenewalPKCS7, enrollSimpleMachineCert, and enrollSimpleUserCert samples.
findCertByKeyUsage Enumerates the personal certificate store of the current user to find the first certificate for which the intended use of the public key matches a specified value. The value specified can be a bitwise combination of the following flags:
  • CERT_DATA_ENCIPHERMENT_KEY_USAGE
  • CERT_DIGITAL_SIGNATURE_KEY_USAGE
  • CERT_KEY_AGREEMENT_KEY_USAGE
  • CERT_KEY_CERT_SIGN_KEY_USAGE
  • CERT_KEY_ENCIPHERMENT_KEY_USAGE
  • CERT_NON_REPUDIATION_KEY_USAGE
  • CERT_OFFLINE_CRL_SIGN_KEY_USAGE
This function is used by the enrollFromPublicKey sample.
findCertByEKU Enumerates the personal certificate store of the current user to find the first certificate for which the Enhanced Key Usage (EKU) extension matches that specified on input. For more information about the EKU extension, see the IX509ExtensionEnhancedKeyUsage interface. This function is used by the enrollEOBOCMC sample.
findCertByTemplate Enumerates the personal certificate store of the current user to find the first certificate for which the template matches that specified, by name, on input. This function is used by the enrollPKCS7 and enrollRenewalPKCS7 samples.
enrollCertByTemplate Initializes an IX509Enrollment object by using a template, attempts to enroll the implicitly created certificate request, and monitors the status of the enrollment process. This function is used by the enrollEOBOCMC, enrollFromPublicKey, enrollPKCS7, and enrollRenewalPKCS7 samples.
verifyCertContext Verifies compliance of the certificate chain against the specified (base) policy and, optionally, against a specified Enhanced Key Usage (EKU) extension. For more information, see the CertVerifyCertificateChainPolicy function and the CERT_CHAIN_POLICY_PARA and CERT_CHAIN_PARA structures. This function is used by the enrollEOBOCMC, enrollFromPublicKey, enrollPKCS7, and enrollRenewalPKCS7 samples.
decConvertFromUnicode Converts a string of double-byte Unicode characters to a string of single-byte ANSI characters. This function is used by the DecodeFileW function defined in enrollCommon.cpp.
DecodeFileW Decodes an encoded certificate or certificate request file to a byte array. This function is used by the installResponseFromPFX sample.
EncodeToFileW Encodes a certificate or certificate request and saves it to a file. This function is used by the createCNGCustomCMC, enrollEOBOCMC, and enrollFromPublicKey samples.
findOIDFromTemplateName Retrieves the object identifier for a template specified by name. This function is used by the findCertByTemplate function defined in enrollCommon.cpp.

Using the Included Samples