The CertFindExtension function finds the first extension in the CERT_EXTENSION array, as identified by its Object Identifier. Processing a decoded certificate is one way this function gets used. From the decoded certificate, a CERT_INFO structure is derived. From that structure the rgExtension array is retrieved and passed to this function in rgExtensions[]. Then this function can determine whether a particular extension is in the array, and if so, return a pointer to it.
#include <wincrypt.h>
PCERT_EXTENSION WINAPI CertFindExtension(
LPCSTR pszObjId, // in
DWORD cExtensions, // in
CERT_EXTENSION rgExtensions[ ] // in
);
Returns a pointer to the extension, if one is found. Otherwise, NULL is returned.
// EXAMPLE CODE FOR USING CertFindExtension.
// Finds the first extension in the CERT_EXTENSION
// array, as identified by its Object Identifier.
// Set up the variables.
LPCSTR pszObjId = szOID_RSA_RC4; // Object identifier
DWORD cExtensions = 128; // # of extensions
CERT_EXTENSION rExtensions[128]; // Array of extensions
CERT_EXTENSION * pResult; // Pointer to the returned extension
pResult = CertFindExtension(
pszObjId, // in - Pointer to object identifier
cExtensions, // in - # of extensions in the array
rExtensions); // in - The array of attributes
if (!&pResult) {
cout<< "no extension found "<< endl;
}
else {
cout<< "extension found at "<< pResult<< endl;
}
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.
CertFindAttribute, CertFindRDNAttr