CertSetEnhancedKeyUsage

The CertSetEnhancedKeyUsage function sets the enhanced key usage property for the certificate.

#include <wincrypt.h>
BOOL WINAPI CertSetEnhancedKeyUsage(
  PCCERT_CONTEXT pCertContext,    // in
  PCERT_ENHKEY_USAGE pUsage       // in
);
 

Parameters

pCertContext
A pointer to the specified certificate.
pUsage
A pointer to the enhanced key usage information to set.

Return Values

TRUE if the function succeeded, FALSE if the function failed.

Call GetLastError to see the reason for any failures.

Example

// EXAMPLE CODE FOR USING CertSetEnhancedKeyUsage.
// Sets the enhanced key usage property for the certificate.
// Assume that a pointer to the certificate (pCertContext) and a
// pointer to the key usage information (pUsage) is already known.

// Set up the variables.
PCCERT_CONTEXT pCertContext; // Initialized elsewhere.
PCERT_ENHKEY_USAGE pUsage;   // Initialized elsewhere.
BOOL fResult;                // Returned TRUE if function successful.
                             //   False if function failed

fResult = CertSetEnhancedKeyUsage(
            pCertContext,    // in - Pointer to the certificate 
            pUsage);         // in - Pointer to the key usage
                             //   identifier

if (!fResult) {              // FALSE
  cout<< "functional failed"<< endl
      << "error code = "<< GetLastError ()<< endl;
}
else {                       // TRUE
  cout<< "function succeeded"<< endl;
}
 

QuickInfo

  Windows NT: Requires version 4.0 SP3 or later. Available also in IE 3.02 and later.
  Windows: Requires Windows 98 (or Windows 95 with IE 3.02 or later).
  Windows CE: Unsupported.
  Header: Declared in wincrypt.h.
  Import Library: Use crypt32.lib.

See Also

CertGetEnhancedKeyUsage