CryptGetObjectUrl

[This is preliminary documentation and subject to change.]

The CryptGetObjectUrl function gets the URL of the remote object from a certificate, CTL, or CRL.

The function takes the object, decodes it, and provides a pointer to an array of URLs from the object. For example; from a certificate, a CRL distribution list (URLs) would be in the array.

#include <wincrypt.h>
BOOL WINAPI CryptGetObjectUrl(
  LPCSTR pszUrlOid,                // in
  LPVOID pvPara,                   // in
  DWORD dwFlags,                   // in
  PCRYPT_URL_ARRAY pUrlArray,      // out/optional
  DWORD* pcbUrlArray,              // in/out
  PCRYPT_URL_INFO pUrlInfo,        // out/optional
  DWORD* pcbUrlInfo,               // in/out/optional
  LPVOID pvReserved                // in/optional
);
 

Parameters

pszUrlOid
Pointer to the object identifier that identifies the URL being requested. If the HIWORD of the pszUrlOid parameter is zero, the LOWORD specifies the integer identifier for the type of the given structure.

OIDs extend the functionality of the CryptoAPI. See OID Overview for additional information.

Support for registering the new functionality in a system registry must be provided in the new DLL along with the new function. See Registering the New Functionality.

See The following table is a list of currently supported OIDs:
OID OID value Meaning
URL_OID_
CERTIFICATE_
ISSUER
(LPCSTR)1 Given a certificate, provides the URL of the certificate issuer. This will be retrieved from the authority info access extension or property on the certificate.
URL_OID_
CERTIFICATE_CRL_
DIST_POINT
(LPCSTR)2 Given a certificate, provides a list URLs of the CRL distribution points. This will be retrieved from the CRL distribution point extension or property on the certificate.
URL_OID_CTL_
ISSUER
(LPCSTR)3 Given a CTL, provides the URL of the CTL issuer. This will be retrieved from an authority info access attribute method encoded in each signer info in the PKCS #7 (CTL).
URL_OID_CTL_
NEXT_UPDATE
(LPCSTR)4 Given a CTL, provides the URL of the next update of that CTL. This is retrieved from an authority info access CTL extension, property, or signer info attribute method.
URL_OID_CRL_
ISSUER
(LPCSTR)5 Given a CRL, provides the URL of the CRL issuer. This is retrieved from a property on the CRL that was inherited from the subject certificate (either from the subject certificate issuer or the subject certificate distribution point extension). It is encoded as an authority info access extension method.

pvPara
If pszUrlOid is URL_OID_CERTIFICATE_ISSUER;
pvPara is a PCCERT_CONTEXT. Pointer to a certificate whose issuer's URL is being requested. This is retrieved from the authority info access extension or property on the certificate.
If pszUrlOid is URL_OID_CERTIFICATE_CRL_DIST_POINT;
pvPara is a PCCERT_CONTEXT. Pointer to a certificate whose CRL distribution point is requested. This is retrieved from the CRL distribution point extension or property on the certificate.
If pszUrlOid is URL_OID_CTL_ISSUER;
pvPara is a PCCTL_CONTEXT. Pointer to a Signer Index CTL whose issuer's URL (identified by the signer index) is requested. This is retrieved from the authority info access attribute method encoded in each signer info in the PKCS #7 (CTL).
If pszUrlOid is URL_OID_CTL_NEXT_UPDATE;
pvPara is a PCCTL_CONTEXT. Pointer to a Signer Index CTL, whose next update URL is requested, and an optional signer index, in case it is needed to check the signer info attributes. This is retrieved from the authority info access CTL extension, property, or signer info attribute method.
If pszUrlOid is URL_OID_CRL ISSUER;
pvPara is a PCCRL_CONTEXT. Pointer to a CRL whose issuer's URL is requested. This is retrieved from a property on the CRL which is inherited from the subject certificate (either from the subject certificate issuer or the subject certificate distribution point extension). It is encoded as an authority info access extension method.
dwFlags
Flag values. This parameter is used to get the URL locator for an object.
Flag value Description
CRYPT_GET_URL_
FROM_PROPERTY
Locates the URL from the object's property (the location of the data).
CRYPT_GET_URL_
FROM_EXTENSION
Locates the URL from the object's extension.
CRYPT_GET_URL_
FROM_UNAUTH_
ATTRIBUTE
Locates the URL from an unauthenticated attribute from the signer info data.
CRYPT_GET_URL_
FROM_AUTH_
ATTRIBUTE
Locates the URL from an authenticated attribute from the signer info data.

pUrlArray
Pointer to a buffer that receives the data for the value entry. This parameter can be NULL if the data is not required.

For more information, see Common In/Out Parameter Conventions.

pcbUrlArray
Pointer to a variable that specifies the size, in bytes, of the buffer pointed to by the pUrlArray parameter. When the function returns, the variable pointed to by the pcbUrlArray parameter contains the number of bytes stored in the buffer. This parameter can be NULL, only if pUrlArray is NULL.
pUrlInfo
Pointer to a buffer that receives the data for the value entry. This parameter can be NULL if the data is not required.

For more information, see Common In/Out Parameter Conventions.

pcbUrlInfo
Pointer to a variable that specifies the size, in bytes, of the buffer pointed to by the pUrlInfo parameter. When the function returns, the variable pointed to by pcbUrlInfo paramater contains the number of bytes stored in the buffer. This parameter can be NULL, only if pUrlInfo is NULL.

Note  When processing the data returned in the buffer, applications need to use the actual size of the data returned. The actual size may be slightly smaller than the size of the buffer specified on input. (On input, buffer sizes are usually specified large enough to ensure that the largest possible output data will fit in the buffer.) On output, the variable pointed to by this parameter is updated to reflect the actual size of the data copied to the buffer.

pvReserved
This parameter is reserved for future use and should always be set to NULL.

Return Values

If the function succeeds, the return value is TRUE. If it does not succeed, the return value is FALSE. To retrieve extended error information, use the GetLastError function.

Remarks

CryptGetObjectUrl has the same signature as UrlDllGetObjectUrl. The developer can implement a UrlDllGetObjectUrl with the signature of CryptGetObjectUrl and install it for the OID.

Example

// EXAMPLE CODE FOR USING CryptGetObjectUrl().
// Assume that a pointer to URL in a PCCTL_CONTEXT
// (pvPara) is already known.

// Set up the variables.
LPCSTR  pszUrlOid;        // Pointer to object identifier
PCCTL_CONTEXT  *pvPara;   // Pointer to URL
DWORD dwFlags;            // Flag values
PCRYPT_URL_ARRAY  pUrlArray= NULL;
                          // Pointer to URl array- initialize to NULL
DWORD cbUrlArray;
PCRYPT_URL_INFO  pUrlInfo= NULL;
                          // Pointer to URL buffer- initialize to NULL
DWORD cbUrlInfo;
LPVOID *pvReserved;       // Reserved for future use
BOOL fResult;             // Return value- True if function successful
                          //   False if function fails

// first call to CryptGetObjectUrl to get the size of array length
fResult= CryptGetObjectUrl(
           URL_OID_CTL_ISSUER,// in- pszUrlOid- Get the URL from a CTL
                              //   ISSUER
           pvPara,            // in- Pointer to a signer index
                              //  initialized elsewhere
           CRYPT_GET_URL_FROM_PROPERTY,
                              // in- dwFlags 
           NULL,              // out/optional- pUrlArray- set to NULL
                              //   to allocate memory
           &cbUrlArray,       // in/out- pUrlArray array length
           NULL,              // out/optional- pUrlInfo- set to NULL
                              //   to allocate memory
           &cbUrlInfo,        // in/out/optional- pUrlInfo size
           NULL);             // in/optional- pvReserved

if (fResult){                 // returned value is TRUE
                              //   CryptGetObjectUrl is successful
  cout<< "First call to CryptGetObjectUrl successful"<< endl;
  pUrlArray = (PCRYPT_URL_ARRAY)malloc (cbUrlArray);
  pUrlInfo = (PCRYPT_URL_INFO)malloc (cbUrlInfo);
  cout<< "memory allocated" << endl;
}
else {                        // returned value is FALSE
  cout<< "First call to CryptGetObjectUrl failed"<< endl;
}

// Function call to get the URL
fResult= CryptGetObjectUrl(
           URL_OID_CTL_ISSUER,// in- pszUrlOid- Get the URL from a CTL
                              //   ISSUER
           pvPara,            // in- Pointer to a signer index
                              //  initialized elsewhere
           CRYPT_GET_URL_FROM_PROPERTY,
                              // in- dwFlags 
           pUrlArray,         // out/optional- pUrlArray
           &cbUrlArray,       // in/out- pUrlArray array length
           pUrlInfo,          // out/optional- pUrlInfo
           &cbUrlInfo,        // in/out/optional- pUrlInfo size
           NULL);             // in/optional- pvReserved

if (fResult){                 // returned value is TRUE
                              //   CryptGetObjectUrl is successful
  cout<< "Second call to CryptGetObjectUrl successful"<< endl
      << "The URL is "<< pUrlInfo<< endl;
}
else {                        // returned value is FALSE    
  cout<< "Second call to CryptGetObjectUrl failed"<< endl
      << "error code = "<< GetLastError<< endl;
}

// free memory
free(pUrlArray);
free(pUrlInfo);
 

QuickInfo

  Windows NT: Requires version 5.0 or later.
  Windows: Unsupported.
  Windows CE: Unsupported.
  Header: Declared in wincrypt.h.
  Import Library: Use cryptnet.lib.