The CertGetSubjectCertificateFromStore function gets the subject certificate context that is uniquely identified by its issuer and serial number from the certificate store.
#include <wincrypt.h>
PCCERT_CONTEXT WINAPI CertGetSubjectCertificateFromStore(
HCERTSTORE hCertStore, // in
DWORD dwCertEncodingType, // in
PCERT_INFO pCertId // in
);
Encoding type | Value |
---|---|
X509_ASN_ENCODING | 0x00000001 |
A pointer to a read-only CERT_CONTEXT is returned. The CERT_CONTEXT must be freed by calling CertFreeCertificateContext.
The returned certificate might not be valid. Normally, it would be verified when getting its issuer certificate (CertGetIssuerCertificateFromStore).
Call GetLastError to see the reason for any failures. This function has the following error codes:
Error code | Description |
---|---|
CRYPT_E_NOT_FOUND | Unable to find the subject certificate in the store. |
CertDuplicateCertificateContext can be called to make a duplicate certificate.
See Signed Message Example Code.
Windows NT: Requires version 4.0 SP3 or later. Available also in IE 3.02 and later.
Windows: Requires Windows 95 OSR2 or later.
Windows CE: Unsupported.
Header: Declared in wincrypt.h.
Import Library: Use crypt32.lib.
CertGetIssuerCertificateFromStore