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