[This is preliminary documentation and subject to change.]
The CryptGetTimeValidObject function gets the object whose validity period covers the specified time values.
The object (CTL, CRL, or certificate) is returned via the ppvObject parameter.
#include <wincrypt.h>
BOOL WINAPI CryptGetTimeValidObject(
LPCSTR pszTimeValidOid, // in
LPVOID pvPara, // in
PCCERT_CONTEXT pIssuer, // in
LPFILETIME pftValidFor, // in/optional
DWORD dwFlags, // in
DWORD dwTimeout, // in
LPVOID* ppvObject, // out/optional
PCRYPT_CREDENTIALS pCredentials, // in/optional
LPVOID pvReserved // in/optional
);
OIDs extend the functionality of the CryptoAPI. See OID Overview for additional information.
The following table lists currently supported OIDs:
OID | Meaning |
---|---|
TIME_VALID_OID_ GET_CTL |
Gets the next time valid CTL. |
TIME_VALID_OID_ GET_CRL |
Gets the next time valid CRL. |
TIME_VALID_OID_ GET_CRL_FROM_CERT |
Gets the next time valid CRL from the certificate. |
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.
TimeValidDllGetObject has the same signature as CryptGetTimeValidObject. The developer can implement a TimeValidDllGetObject with the signature of CryptGetTimeValidObject and install it for the OID.
// EXAMPLE CODE FOR USING CryptGetTimeValidObject().
// Assume that pointers to a CRL context (pvPara) and the
// certificate issuer (pIssuer) are already known.
// Set up the variables.
LPCSTR pszTimeValidOid; // Pointer to a time Valid OID
PCCRL_CONTEXT pvPara; // Pointer to a PCCRL_CONTEXT to get the
// time valid object- a PCCRL_CONTEXT
// because the OID is a CRL.
PCCERT_CONTEXT pIssuer; // Pointer to a certificate's issuer
LPFILETIME pftValidFor; // Pointer to the FILETIME structure
DWORD dwFlags; // Flag values- future use- set to 0
DWORD dwTimeout; // Time out value (set to 0)-
// Not used in Windows NT 5.0 Beta
PCCRL_CONTEXT* ppvObject; // Pointer to address of the object
PCRYPT_CREDENTIALS pCredentials;
// Pointer to the Credentials structure
LPVOID pvReserved; // Reserved for future use- set to NULL
BOOL fResult; // Return value- True if function successful
// False if function fails
// call to CryptGetTimeValidObject to get the
// ThisUpdate and NextUpdate time.
fResult= CryptGetTimeValidObject(
TIME_VALID_OID_GET_CRL,
// in- pszTimeValidOid
(LPVOID)pvPara, // in- Initialized elsewhere
pIssuer, // in- Initialized elsewhere
NULL, // in/optional- pftValidFor set to NULL,
// use current time.
0, // in- dwFlags- set to 0
0, // in- timeout value- set to 0
(LPVOID*)ppvObject,
// out/optional-
NULL, // in/optional-pCredentials set to NULL,
// using cache only
NULL); // in/optional- Reserved- set to NULL
if (fResult){ // returned value is TRUE
// CryptGetTimeValidObject is successful
cout<< "Call to CryptGetTimeValidObject successful"<< endl
<< "Pointer to the address (ppvObject) = "<< ppvObject<< endl
<< "ThisUpdate = "<< (*ppvObject)->
pCrlInfo->ThisUpdate.dwLowDateTime<< endl
<< "NextUpdate = "<< (*ppvObject)->
pCrlInfo->NextUpdate.dwLowDateTime<< endl<< endl;
}
else { // returned value is FALSE
cout<< "Call to CryptGetTimeValidObject failed"<< endl
<< "error code = "<< GetLastError<< endl;
}
// free memory
CertFreeCRLContext (*ppvObject);
Windows NT: Requires version 5.0 or later.
Windows: Unsupported.
Windows CE: Unsupported.
Header: Declared in wincrypt.h.
Import Library: Use cryptnet.lib.