Export (0) Print
Expand All

IBackgroundCopyJobHttpOptions::GetClientCertificate method

Retrieves the client certificate from the job.

Syntax


HRESULT GetClientCertificate(
  [out]  BG_CERT_STORE_LOCATION *pStoreLocation,
  [out]  LPWSTR *pStoreName,
  [out]  byte **ppCertHashBlob,
  [out]  LPWSTR *pSubjectName
);

Parameters

pStoreLocation [out]

Identifies the location of a system store to use for looking up the certificate. For possible values, see the BG_CERT_STORE_LOCATION enumeration.

pStoreName [out]

Null-terminated string that contains the name of the certificate store. To free the string when done, call the CoTaskMemFree function.

ppCertHashBlob [out]

SHA1 hash that identifies the certificate. To free the blob when done, call the CoTaskMemFree function.

pSubjectName [out]

Null-terminated string that contains the simple subject name of the certificate. The RDNs in the subject name are in the reverse order from what the certificate displays. Subject name can be empty if the certificate does not contain a subject name. To free the string when done, call the CoTaskMemFree function.

Return value

The following table lists some of the possible return values.

Return codeDescription
S_OK

Successfully retrieved the certificate.

RPC_X_BAD_STUB_DATA

The job does not specify a certificate or the user does not have permissions to the certificate.

RPC_X_NULL_REF_POINTER

One of the parameters is NULL.

 

Remarks

You use the IBackgroundCopyJobHttpOptions::SetClientCertificateByID or IBackgroundCopyJobHttpOptions::SetClientCertificateByName method to specify the certificate.

Examples

The following example shows how to retrieve information about the client certificate. The example assumes pJob points to a valid job.


#define THUMBPRINT_SIZE 20

  HRESULT hr = S_OK;
  IBackgroundCopyJob* pJob = NULL;
  IBackgroundCopyJobHttpOptions* pHttpOptions = NULL;
  GUID JobId;

  BG_CERT_STORE_LOCATION StoreLocation;
  LPWSTR pStoreName = NULL;
  BYTE* pThumbprint = NULL;
  LPWSTR pSubjectName = NULL;

  // Retrieve a pointer to the IBackgroundCopyJobHttpOptions interface.
  hr = pJob->QueryInterface(__uuidof(IBackgroundCopyJobHttpOptions), (void**)&pHttpOptions);
  pJob->Release();
  if (FAILED(hr))
  {
    wprintf(L"pJob->QueryInterface failed with 0x%x.\n", hr);
    goto cleanup;
  }

  // Retrieve information about the client certificate set on the job. 
  hr = pHttpOptions->GetClientCertificate(&StoreLocation, &pStoreName, 
         &pThumbprint, &pSubjectName);
  if (S_OK == hr)
  {
    wprintf(L"\nLocation: %d\nStore name: %s\nSubject: %s\n", 
        StoreLocation, pStoreName, pSubjectName);

    wprintf(L"Thumbprint: ");
    for (DWORD i = 0; i < THUMBPRINT_SIZE; i++)
    {
      wprintf(L"%x ", pThumbprint[i]);
    }
    wprintf(L"\n");

    CoTaskMemFree(pStoreName);
    CoTaskMemFree(pThumbprint);
    CoTaskMemFree(pSubjectName);
  }
  else if (RPC_X_BAD_STUB_DATA == hr)
  {
    wprintf(L"The job does not specify a client certificate or\n"
            L"the user does not have permission to access the certificate.\n");
  }
  else
  {
    wprintf(L"pHttpOptions->GetClientCertificate failed with 0x%x.\n", hr);
    goto cleanup;
  }


cleanup:

  if (pHttpOptions)
  {
    hr = pHttpOptions->Release();
  }


Requirements

Minimum supported client

Windows Vista

Minimum supported server

Windows Server 2008

Header

Bits2_5.h (include Bits.h)

IDL

Bits2_5.idl

Library

Bits.lib

See also

IBackgroundCopyJobHttpOptions
IBackgroundCopyJobHttpOptions::RemoveClientCertificate
IBackgroundCopyJobHttpOptions::SetClientCertificateByID
IBackgroundCopyJobHttpOptions::SetClientCertificateByName

 

 

Community Additions

ADD
Show:
© 2014 Microsoft