CertFindAttribute

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
);
 

Parameters

pszObjId
A pointer to the Object Identifier to use in the search.
cAttr
The number of attributes in rgAttr[].
rgAttr[]
The array of attributes.

Return Values

Returns a pointer to the attribute, if one is found. Otherwise, NULL is returned.

Example

// 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;
}
 

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

CertFindExtension, CertFindRDNAttr