Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

This function returns from a certificate store a subject certificate context uniquely identified by its issuer and serial number.

Syntax

PCCERT_CONTEXT WINAPI CertGetSubjectCertificateFromStore(
  HCERTSTORE 
hCertStore,
  DWORD 
dwCertEncodingType,
  PCERT_INFO 
pCertId
);

Parameters

hCertStore

[in] Handle to a certificate store.

dwCertEncodingType

[in] Specifies the type of encoding used. Currently, only X509_ASN_ENCODING is used; however, additional encoding types may be added in the future.

pCertId

[in] Pointer to a CERT_INFOstructure. Only the Issuerand SerialNumbermembers are used.

Return Value

If the function succeeds, the return value is a pointer to a read-only CERT_CONTEXT. The CERT_CONTEXTstructure must be freed by calling the CertFreeCertificateContextfunction.

The returned certificate might not be valid. Usually, it is verified when using CertGetIssuerCertificateFromStoreto get its issuer certificate.

For extended error information, call the GetLastErrorfunction.

The GetLastErrorfunction can return CRYPT_E_NOT_FOUND, which mean that the subject certificate was not found in the store.

Remarks

The CertDuplicateCertificateContextfunction can be called to make a duplicate certificate.

The desktop operating system supports the flag PKCS_7_ASN_ENCODING, but Windows Embedded CE does not and ignores the flag when it is specified.

Requirements

Header wincrypt.h
Library crypt32.lib
Windows Embedded CE Windows CE 3.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also