CertSetEnhancedKeyUsage function

The CertSetEnhancedKeyUsage function sets the enhanced key usage (EKU) property for the certificate. Use of this function replaces any EKUs associated with the certificate. To add a single EKU usage without changing existing usages, use CertAddEnhancedKeyUsageIdentifier. To delete a single EKU usage, use CertRemoveEnhancedKeyUsageIdentifier.

Syntax

BOOL CertSetEnhancedKeyUsage(
  PCCERT_CONTEXT     pCertContext,
  PCERT_ENHKEY_USAGE pUsage
);

Parameters

pCertContext

A pointer to the CERT_CONTEXT of the specified certificate.

pUsage

Pointer to a CERT_ENHKEY_USAGE structure (equivalent to a CTL_USAGE structure) that contains an array of EKU object identifiers (OIDs) to be set as extended properties of the certificate.

Return Value

If the function succeeds, the function returns nonzero (TRUE).

If the function fails, it returns zero (FALSE). For extended error information, call GetLastError.

Requirements

   
Minimum supported client Windows XP [desktop apps only]
Minimum supported server Windows Server 2003 [desktop apps only]
Target Platform Windows
Header wincrypt.h
Library Crypt32.lib
DLL Crypt32.dll

See Also

CertGetEnhancedKeyUsage

Enhanced Key Usage Functions