Platform SDK: Certificate Enrollment Control

ICEnroll::getCertFromPKCS7 [C++]

CEnroll.getCertFromPKCS7 [Visual Basic]

The getCertFromPKCS7 method is used to retrieve from a PKCS #7 just the single certificate that was issued. (The PKCS #7 may contain many certificates specifying the certification chain of authority that issued the certificate.)

[Visual Basic]
objEnroll.getCertFromPKCS7( _
            wszPKCS7 As String ) As String
[C++]
HRESULT getCertFromPKCS7(
  BSTR wszPKCS7,      // in
  BSTR *pbstrCert     // out
);

Parameters

[Visual Basic] objEnroll
Object expression that resolves to a CEnroll object.
[Visual Basic,C++] wszPKCS7
Specifies the PKCS #7 from which the issued certificate is being retrieved.
[C++] pbstrCert
Pointer to a BSTR variable which will contain the issued certificate. It is the responsibility of the caller to free this variable (via SysFreeString).

Return Values

[Visual Basic] None.

[C++] The return value is an HRESULT. A value of S_OK indicates success. Upon successful completion of this function, *pbstrCert will contain the certificate that was issued.

Example Code [C++]

BSTR    bstrCert = NULL;
HRESULT    hr;

// pEnroll is previously instantiated ICEnroll interface pointer
// bstrPKCS7 is previously created BSTR containing PCKS7
hr = pEnroll->getCertFromPKCS7( bstrPKCS7, &bstrCert );
if (FAILED(hr))
    printf("Failed getCertFromPKCS7 - %x\n", hr );
else
{
    printf("Successfully called getCertFromPKCS7\n");   
    // do something with the certificate
}

// free BSTR when done
if ( NULL != bstrCert )
    SysFreeString( bstrCert );

Example Code [Visual Basic]

    On Error GoTo Err_GetCert
    
    ' strPKCS7 is a String variable containing PKCS7
    strCert = objEnroll.getCertFromPKCS7(strPKCS7)
    MsgBox ("Retrieved certificate: " & _
            strCert)
    Exit Sub

Err_GetCert:
    
    MsgBox ("Failed getCertFromPKCS7")

    End Sub

Requirements

  Windows NT/2000: Requires Windows 2000 (or Windows NT 4.0 with the Windows NT 4.0 Option Pack).
  Header: Declared in Xenroll.h.
  Library: Use Uuid.lib.