//---------------------------------------------------------------------------

#pragma hdrstop
#include <windows.h>
#include <wincrypt.h>
#include <stdio.h>
//---------------------------------------------------------------------------
#define MY_ENCODING_TYPE  (PKCS_7_ASN_ENCODING | X509_ASN_ENCODING)
#pragma argsused
int main(int argc, char* argv[])
{
HCERTSTORE Store;
PCCERT_CONTEXT pCertContextArray[1];
PCCERT_CONTEXT pCertContext;
CERT_REVOCATION_STATUS  revStatus ;
CERT_NAME_BLOB  SubjNameBlob;
DWORD err;
Store = CertOpenSystemStore(0,"MY");      // открываем локальное хранилище MY
pCertContext = CertFindCertificateInStore(Store,MY_ENCODING_TYPE,0,CERT_FIND_SUBJECT_STR,L"User01",NULL);//находим проверяемый сертификат
if (pCertContext==NULL)
{
        printf("Cert not found");
        return 1;
}
pCertContextArray[0] =pCertContext;
revStatus.cbSize =sizeof(CERT_REVOCATION_STATUS);
// вызываем функцию получения статуса сертификата (OCSP)
if (!CertVerifyRevocation(MY_ENCODING_TYPE,CERT_CONTEXT_REVOCATION_TYPE ,1,(void**)pCertContextArray, CERT_VERIFY_REV_CHAIN_FLAG, NULL, &revStatus))
{
        err = GetLastError();
        if (err == E_INVALIDARG) printf("Invalid argument");
        if (err == CRYPT_E_REVOCATION_OFFLINE) printf("Cannot connect to server");
        if (err == CRYPT_E_NO_REVOCATION_CHECK) printf("Status is unknown");
        if (err == CRYPT_E_REVOKED) printf("Revoked");
}
else
{
 printf("Status is OK");
}
if (pCertContext)  CertFreeCertificateContext(pCertContext);
if (Store) CertCloseStore(Store,0);
return 0;
}
//---------------------------------------------------------------------------

