This source file includes following definitions.
- MapSecurityError
- MapCertChainErrorStatusToCertStatus
- CertSubjectCommonNameHasNull
- IsIssuedByKnownRoot
- GetCertChainInfo
- GetCertPoliciesInfo
- CheckRevocationWithCRLSet
- AppendPublicKeyHashes
- CheckEV
- SupportsAdditionalTrustAnchors
- VerifyInternal
#include "net/cert/cert_verify_proc_win.h"
#include <string>
#include <vector>
#include "base/memory/scoped_ptr.h"
#include "base/sha1.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "crypto/capi_util.h"
#include "crypto/scoped_capi_types.h"
#include "crypto/sha2.h"
#include "net/base/net_errors.h"
#include "net/cert/asn1_util.h"
#include "net/cert/cert_status_flags.h"
#include "net/cert/cert_verifier.h"
#include "net/cert/cert_verify_result.h"
#include "net/cert/crl_set.h"
#include "net/cert/ev_root_ca_metadata.h"
#include "net/cert/test_root_certs.h"
#include "net/cert/x509_certificate.h"
#include "net/cert/x509_certificate_known_roots_win.h"
#pragma comment(lib, "crypt32.lib")
#if !defined(CERT_TRUST_HAS_WEAK_SIGNATURE)
#define CERT_TRUST_HAS_WEAK_SIGNATURE 0x00100000
#endif
namespace net {
namespace {
struct FreeChainEngineFunctor {
void operator()(HCERTCHAINENGINE engine) const {
if (engine)
CertFreeCertificateChainEngine(engine);
}
};
struct FreeCertChainContextFunctor {
void operator()(PCCERT_CHAIN_CONTEXT chain_context) const {
if (chain_context)
CertFreeCertificateChain(chain_context);
}
};
struct FreeCertContextFunctor {
void operator()(PCCERT_CONTEXT context) const {
if (context)
CertFreeCertificateContext(context);
}
};
typedef crypto::ScopedCAPIHandle<HCERTCHAINENGINE, FreeChainEngineFunctor>
ScopedHCERTCHAINENGINE;
typedef scoped_ptr<const CERT_CHAIN_CONTEXT, FreeCertChainContextFunctor>
ScopedPCCERT_CHAIN_CONTEXT;
typedef scoped_ptr<const CERT_CONTEXT, FreeCertContextFunctor>
ScopedPCCERT_CONTEXT;
int MapSecurityError(SECURITY_STATUS err) {
switch (err) {
case SEC_E_WRONG_PRINCIPAL:
case CERT_E_CN_NO_MATCH:
return ERR_CERT_COMMON_NAME_INVALID;
case SEC_E_UNTRUSTED_ROOT:
case CERT_E_UNTRUSTEDROOT:
return ERR_CERT_AUTHORITY_INVALID;
case SEC_E_CERT_EXPIRED:
case CERT_E_EXPIRED:
return ERR_CERT_DATE_INVALID;
case CRYPT_E_NO_REVOCATION_CHECK:
return ERR_CERT_NO_REVOCATION_MECHANISM;
case CRYPT_E_REVOCATION_OFFLINE:
return ERR_CERT_UNABLE_TO_CHECK_REVOCATION;
case CRYPT_E_REVOKED:
return ERR_CERT_REVOKED;
case SEC_E_CERT_UNKNOWN:
case CERT_E_ROLE:
return ERR_CERT_INVALID;
case CERT_E_WRONG_USAGE:
return ERR_CERT_INVALID;
case SEC_E_ILLEGAL_MESSAGE:
return ERR_SSL_PROTOCOL_ERROR;
case SEC_E_ALGORITHM_MISMATCH:
return ERR_SSL_VERSION_OR_CIPHER_MISMATCH;
case SEC_E_INVALID_HANDLE:
return ERR_UNEXPECTED;
case SEC_E_OK:
return OK;
default:
LOG(WARNING) << "Unknown error " << err << " mapped to net::ERR_FAILED";
return ERR_FAILED;
}
}
int MapCertChainErrorStatusToCertStatus(DWORD error_status) {
CertStatus cert_status = 0;
const DWORD kDateInvalidErrors = CERT_TRUST_IS_NOT_TIME_VALID |
CERT_TRUST_CTL_IS_NOT_TIME_VALID;
if (error_status & kDateInvalidErrors)
cert_status |= CERT_STATUS_DATE_INVALID;
const DWORD kAuthorityInvalidErrors = CERT_TRUST_IS_UNTRUSTED_ROOT |
CERT_TRUST_IS_EXPLICIT_DISTRUST |
CERT_TRUST_IS_PARTIAL_CHAIN;
if (error_status & kAuthorityInvalidErrors)
cert_status |= CERT_STATUS_AUTHORITY_INVALID;
if ((error_status & CERT_TRUST_REVOCATION_STATUS_UNKNOWN) &&
!(error_status & CERT_TRUST_IS_OFFLINE_REVOCATION))
cert_status |= CERT_STATUS_NO_REVOCATION_MECHANISM;
if (error_status & CERT_TRUST_IS_OFFLINE_REVOCATION)
cert_status |= CERT_STATUS_UNABLE_TO_CHECK_REVOCATION;
if (error_status & CERT_TRUST_IS_REVOKED)
cert_status |= CERT_STATUS_REVOKED;
const DWORD kWrongUsageErrors = CERT_TRUST_IS_NOT_VALID_FOR_USAGE |
CERT_TRUST_CTL_IS_NOT_VALID_FOR_USAGE;
if (error_status & kWrongUsageErrors) {
cert_status |= CERT_STATUS_INVALID;
}
if (error_status & CERT_TRUST_IS_NOT_SIGNATURE_VALID) {
if (error_status & CERT_TRUST_HAS_WEAK_SIGNATURE) {
cert_status |= CERT_STATUS_WEAK_KEY;
} else {
cert_status |= CERT_STATUS_INVALID;
}
}
const DWORD kCertInvalidErrors =
CERT_TRUST_IS_CYCLIC |
CERT_TRUST_INVALID_EXTENSION |
CERT_TRUST_INVALID_POLICY_CONSTRAINTS |
CERT_TRUST_INVALID_BASIC_CONSTRAINTS |
CERT_TRUST_INVALID_NAME_CONSTRAINTS |
CERT_TRUST_CTL_IS_NOT_SIGNATURE_VALID |
CERT_TRUST_HAS_NOT_SUPPORTED_NAME_CONSTRAINT |
CERT_TRUST_HAS_NOT_DEFINED_NAME_CONSTRAINT |
CERT_TRUST_HAS_NOT_PERMITTED_NAME_CONSTRAINT |
CERT_TRUST_HAS_EXCLUDED_NAME_CONSTRAINT |
CERT_TRUST_NO_ISSUANCE_CHAIN_POLICY |
CERT_TRUST_HAS_NOT_SUPPORTED_CRITICAL_EXT;
if (error_status & kCertInvalidErrors)
cert_status |= CERT_STATUS_INVALID;
return cert_status;
}
bool CertSubjectCommonNameHasNull(PCCERT_CONTEXT cert) {
CRYPT_DECODE_PARA decode_para;
decode_para.cbSize = sizeof(decode_para);
decode_para.pfnAlloc = crypto::CryptAlloc;
decode_para.pfnFree = crypto::CryptFree;
CERT_NAME_INFO* name_info = NULL;
DWORD name_info_size = 0;
BOOL rv;
rv = CryptDecodeObjectEx(X509_ASN_ENCODING | PKCS_7_ASN_ENCODING,
X509_NAME,
cert->pCertInfo->Subject.pbData,
cert->pCertInfo->Subject.cbData,
CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_NOCOPY_FLAG,
&decode_para,
&name_info,
&name_info_size);
if (rv) {
scoped_ptr<CERT_NAME_INFO, base::FreeDeleter> scoped_name_info(name_info);
for (DWORD i = 0; i < name_info->cRDN; ++i) {
PCERT_RDN rdn = &name_info->rgRDN[i];
for (DWORD j = 0; j < rdn->cRDNAttr; ++j) {
PCERT_RDN_ATTR rdn_attr = &rdn->rgRDNAttr[j];
if (strcmp(rdn_attr->pszObjId, szOID_COMMON_NAME) == 0) {
switch (rdn_attr->dwValueType) {
case CERT_RDN_ENCODED_BLOB:
break;
case CERT_RDN_PRINTABLE_STRING:
case CERT_RDN_TELETEX_STRING:
case CERT_RDN_IA5_STRING:
case CERT_RDN_VISIBLE_STRING:
for (DWORD k = 0; k < rdn_attr->Value.cbData; ++k) {
if (rdn_attr->Value.pbData[k] == '\0')
return true;
}
break;
case CERT_RDN_BMP_STRING:
case CERT_RDN_UTF8_STRING: {
DWORD num_wchars = rdn_attr->Value.cbData / 2;
wchar_t* common_name =
reinterpret_cast<wchar_t*>(rdn_attr->Value.pbData);
for (DWORD k = 0; k < num_wchars; ++k) {
if (common_name[k] == L'\0')
return true;
}
break;
}
case CERT_RDN_UNIVERSAL_STRING: {
DWORD num_ints = rdn_attr->Value.cbData / 4;
int* common_name =
reinterpret_cast<int*>(rdn_attr->Value.pbData);
for (DWORD k = 0; k < num_ints; ++k) {
if (common_name[k] == 0)
return true;
}
break;
}
default:
NOTREACHED();
break;
}
}
}
}
}
return false;
}
bool IsIssuedByKnownRoot(PCCERT_CHAIN_CONTEXT chain_context) {
PCERT_SIMPLE_CHAIN first_chain = chain_context->rgpChain[0];
int num_elements = first_chain->cElement;
if (num_elements < 1)
return false;
PCERT_CHAIN_ELEMENT* element = first_chain->rgpElement;
PCCERT_CONTEXT cert = element[num_elements - 1]->pCertContext;
SHA1HashValue hash = X509Certificate::CalculateFingerprint(cert);
return IsSHA1HashInSortedArray(
hash, &kKnownRootCertSHA1Hashes[0][0], sizeof(kKnownRootCertSHA1Hashes));
}
void GetCertChainInfo(PCCERT_CHAIN_CONTEXT chain_context,
CertVerifyResult* verify_result) {
if (chain_context->cChain == 0)
return;
PCERT_SIMPLE_CHAIN first_chain = chain_context->rgpChain[0];
int num_elements = first_chain->cElement;
PCERT_CHAIN_ELEMENT* element = first_chain->rgpElement;
PCCERT_CONTEXT verified_cert = NULL;
std::vector<PCCERT_CONTEXT> verified_chain;
bool has_root_ca = num_elements > 1 &&
!(chain_context->TrustStatus.dwErrorStatus &
CERT_TRUST_IS_PARTIAL_CHAIN);
if (has_root_ca) {
num_elements -= 1;
}
for (int i = 0; i < num_elements; ++i) {
PCCERT_CONTEXT cert = element[i]->pCertContext;
if (i == 0) {
verified_cert = cert;
} else {
verified_chain.push_back(cert);
}
const char* algorithm = cert->pCertInfo->SignatureAlgorithm.pszObjId;
if (strcmp(algorithm, szOID_RSA_MD5RSA) == 0) {
verify_result->has_md5 = true;
} else if (strcmp(algorithm, szOID_RSA_MD2RSA) == 0) {
verify_result->has_md2 = true;
} else if (strcmp(algorithm, szOID_RSA_MD4RSA) == 0) {
verify_result->has_md4 = true;
}
}
if (verified_cert) {
if (has_root_ca)
verified_chain.push_back(element[num_elements]->pCertContext);
verify_result->verified_cert =
X509Certificate::CreateFromHandle(verified_cert, verified_chain);
}
}
void GetCertPoliciesInfo(
PCCERT_CONTEXT cert,
scoped_ptr<CERT_POLICIES_INFO, base::FreeDeleter>* output) {
PCERT_EXTENSION extension = CertFindExtension(szOID_CERT_POLICIES,
cert->pCertInfo->cExtension,
cert->pCertInfo->rgExtension);
if (!extension)
return;
CRYPT_DECODE_PARA decode_para;
decode_para.cbSize = sizeof(decode_para);
decode_para.pfnAlloc = crypto::CryptAlloc;
decode_para.pfnFree = crypto::CryptFree;
CERT_POLICIES_INFO* policies_info = NULL;
DWORD policies_info_size = 0;
BOOL rv;
rv = CryptDecodeObjectEx(X509_ASN_ENCODING | PKCS_7_ASN_ENCODING,
szOID_CERT_POLICIES,
extension->Value.pbData,
extension->Value.cbData,
CRYPT_DECODE_ALLOC_FLAG | CRYPT_DECODE_NOCOPY_FLAG,
&decode_para,
&policies_info,
&policies_info_size);
if (rv)
output->reset(policies_info);
}
enum CRLSetResult {
kCRLSetOk,
kCRLSetUnknown,
kCRLSetRevoked,
};
CRLSetResult CheckRevocationWithCRLSet(PCCERT_CHAIN_CONTEXT chain,
CRLSet* crl_set) {
if (chain->cChain == 0)
return kCRLSetOk;
const PCERT_SIMPLE_CHAIN first_chain = chain->rgpChain[0];
const PCERT_CHAIN_ELEMENT* element = first_chain->rgpElement;
const int num_elements = first_chain->cElement;
if (num_elements == 0)
return kCRLSetOk;
bool covered = true;
std::string issuer_spki_hash;
for (int i = num_elements - 1; i >= 0; i--) {
PCCERT_CONTEXT cert = element[i]->pCertContext;
base::StringPiece der_bytes(
reinterpret_cast<const char*>(cert->pbCertEncoded),
cert->cbCertEncoded);
base::StringPiece spki;
if (!asn1::ExtractSPKIFromDERCert(der_bytes, &spki)) {
NOTREACHED();
covered = false;
continue;
}
const std::string spki_hash = crypto::SHA256HashString(spki);
const CRYPT_INTEGER_BLOB* serial_blob = &cert->pCertInfo->SerialNumber;
scoped_ptr<uint8[]> serial_bytes(new uint8[serial_blob->cbData]);
for (unsigned j = 0; j < serial_blob->cbData; j++)
serial_bytes[j] = serial_blob->pbData[serial_blob->cbData - j - 1];
base::StringPiece serial(reinterpret_cast<const char*>(serial_bytes.get()),
serial_blob->cbData);
CRLSet::Result result = crl_set->CheckSPKI(spki_hash);
if (result != CRLSet::REVOKED && !issuer_spki_hash.empty())
result = crl_set->CheckSerial(serial, issuer_spki_hash);
issuer_spki_hash = spki_hash;
switch (result) {
case CRLSet::REVOKED:
return kCRLSetRevoked;
case CRLSet::UNKNOWN:
covered = false;
continue;
case CRLSet::GOOD:
continue;
default:
NOTREACHED();
covered = false;
continue;
}
}
if (!covered || crl_set->IsExpired())
return kCRLSetUnknown;
return kCRLSetOk;
}
void AppendPublicKeyHashes(PCCERT_CHAIN_CONTEXT chain,
HashValueVector* hashes) {
if (chain->cChain == 0)
return;
PCERT_SIMPLE_CHAIN first_chain = chain->rgpChain[0];
PCERT_CHAIN_ELEMENT* const element = first_chain->rgpElement;
const DWORD num_elements = first_chain->cElement;
for (DWORD i = 0; i < num_elements; i++) {
PCCERT_CONTEXT cert = element[i]->pCertContext;
base::StringPiece der_bytes(
reinterpret_cast<const char*>(cert->pbCertEncoded),
cert->cbCertEncoded);
base::StringPiece spki_bytes;
if (!asn1::ExtractSPKIFromDERCert(der_bytes, &spki_bytes))
continue;
HashValue sha1(HASH_VALUE_SHA1);
base::SHA1HashBytes(reinterpret_cast<const uint8*>(spki_bytes.data()),
spki_bytes.size(), sha1.data());
hashes->push_back(sha1);
HashValue sha256(HASH_VALUE_SHA256);
crypto::SHA256HashString(spki_bytes, sha256.data(), crypto::kSHA256Length);
hashes->push_back(sha256);
}
}
bool CheckEV(PCCERT_CHAIN_CONTEXT chain_context,
bool rev_checking_enabled,
const char* policy_oid) {
DCHECK_NE(static_cast<DWORD>(0), chain_context->cChain);
DWORD error_status = chain_context->TrustStatus.dwErrorStatus;
if (!rev_checking_enabled) {
error_status &= ~(CERT_TRUST_IS_OFFLINE_REVOCATION |
CERT_TRUST_REVOCATION_STATUS_UNKNOWN);
}
if (!chain_context->cChain || error_status != CERT_TRUST_NO_ERROR)
return false;
PCERT_CHAIN_ELEMENT* element = chain_context->rgpChain[0]->rgpElement;
int num_elements = chain_context->rgpChain[0]->cElement;
if (num_elements < 2)
return false;
PCCERT_CONTEXT root_cert = element[num_elements - 1]->pCertContext;
SHA1HashValue fingerprint =
X509Certificate::CalculateFingerprint(root_cert);
EVRootCAMetadata* metadata = EVRootCAMetadata::GetInstance();
return metadata->HasEVPolicyOID(fingerprint, policy_oid);
}
}
CertVerifyProcWin::CertVerifyProcWin() {}
CertVerifyProcWin::~CertVerifyProcWin() {}
bool CertVerifyProcWin::SupportsAdditionalTrustAnchors() const {
return false;
}
int CertVerifyProcWin::VerifyInternal(
X509Certificate* cert,
const std::string& hostname,
int flags,
CRLSet* crl_set,
const CertificateList& additional_trust_anchors,
CertVerifyResult* verify_result) {
PCCERT_CONTEXT cert_handle = cert->os_cert_handle();
if (!cert_handle)
return ERR_UNEXPECTED;
CERT_CHAIN_PARA chain_para;
memset(&chain_para, 0, sizeof(chain_para));
chain_para.cbSize = sizeof(chain_para);
static const LPSTR usage[] = {
szOID_PKIX_KP_SERVER_AUTH,
szOID_SERVER_GATED_CRYPTO,
szOID_SGC_NETSCAPE
};
chain_para.RequestedUsage.dwType = USAGE_MATCH_TYPE_OR;
chain_para.RequestedUsage.Usage.cUsageIdentifier = arraysize(usage);
chain_para.RequestedUsage.Usage.rgpszUsageIdentifier =
const_cast<LPSTR*>(usage);
scoped_ptr<CERT_POLICIES_INFO, base::FreeDeleter> policies_info;
LPSTR ev_policy_oid = NULL;
if (flags & CertVerifier::VERIFY_EV_CERT) {
GetCertPoliciesInfo(cert_handle, &policies_info);
if (policies_info.get()) {
EVRootCAMetadata* metadata = EVRootCAMetadata::GetInstance();
for (DWORD i = 0; i < policies_info->cPolicyInfo; ++i) {
LPSTR policy_oid = policies_info->rgPolicyInfo[i].pszPolicyIdentifier;
if (metadata->IsEVPolicyOID(policy_oid)) {
ev_policy_oid = policy_oid;
chain_para.RequestedIssuancePolicy.dwType = USAGE_MATCH_TYPE_AND;
chain_para.RequestedIssuancePolicy.Usage.cUsageIdentifier = 1;
chain_para.RequestedIssuancePolicy.Usage.rgpszUsageIdentifier =
&ev_policy_oid;
break;
}
}
}
}
DWORD chain_flags = CERT_CHAIN_CACHE_END_CERT |
CERT_CHAIN_REVOCATION_CHECK_CHAIN_EXCLUDE_ROOT;
bool rev_checking_enabled =
(flags & CertVerifier::VERIFY_REV_CHECKING_ENABLED);
if (rev_checking_enabled) {
verify_result->cert_status |= CERT_STATUS_REV_CHECKING_ENABLED;
} else {
chain_flags |= CERT_CHAIN_REVOCATION_CHECK_CACHE_ONLY;
}
ScopedHCERTCHAINENGINE chain_engine(NULL);
if (TestRootCerts::HasInstance())
chain_engine.reset(TestRootCerts::GetInstance()->GetChainEngine());
ScopedPCCERT_CONTEXT cert_list(cert->CreateOSCertChainForCert());
PCCERT_CHAIN_CONTEXT chain_context;
if (!CertGetCertificateChain(
chain_engine,
cert_list.get(),
NULL,
cert_list->hCertStore,
&chain_para,
chain_flags,
NULL,
&chain_context)) {
verify_result->cert_status |= CERT_STATUS_INVALID;
return MapSecurityError(GetLastError());
}
CRLSetResult crl_set_result = kCRLSetUnknown;
if (crl_set)
crl_set_result = CheckRevocationWithCRLSet(chain_context, crl_set);
if (crl_set_result == kCRLSetRevoked) {
verify_result->cert_status |= CERT_STATUS_REVOKED;
} else if (crl_set_result == kCRLSetUnknown &&
(flags & CertVerifier::VERIFY_REV_CHECKING_ENABLED_EV_ONLY) &&
!rev_checking_enabled &&
ev_policy_oid != NULL) {
rev_checking_enabled = true;
chain_flags &= ~CERT_CHAIN_REVOCATION_CHECK_CACHE_ONLY;
verify_result->cert_status |= CERT_STATUS_REV_CHECKING_ENABLED;
CertFreeCertificateChain(chain_context);
if (!CertGetCertificateChain(
chain_engine,
cert_list.get(),
NULL,
cert_list->hCertStore,
&chain_para,
chain_flags,
NULL,
&chain_context)) {
verify_result->cert_status |= CERT_STATUS_INVALID;
return MapSecurityError(GetLastError());
}
}
if (chain_context->TrustStatus.dwErrorStatus &
CERT_TRUST_IS_NOT_VALID_FOR_USAGE) {
ev_policy_oid = NULL;
chain_para.RequestedIssuancePolicy.Usage.cUsageIdentifier = 0;
chain_para.RequestedIssuancePolicy.Usage.rgpszUsageIdentifier = NULL;
CertFreeCertificateChain(chain_context);
if (!CertGetCertificateChain(
chain_engine,
cert_list.get(),
NULL,
cert_list->hCertStore,
&chain_para,
chain_flags,
NULL,
&chain_context)) {
verify_result->cert_status |= CERT_STATUS_INVALID;
return MapSecurityError(GetLastError());
}
}
CertVerifyResult temp_verify_result = *verify_result;
GetCertChainInfo(chain_context, verify_result);
if (!verify_result->is_issued_by_known_root &&
(flags & CertVerifier::VERIFY_REV_CHECKING_REQUIRED_LOCAL_ANCHORS)) {
*verify_result = temp_verify_result;
rev_checking_enabled = true;
verify_result->cert_status |= CERT_STATUS_REV_CHECKING_ENABLED;
chain_flags &= ~CERT_CHAIN_REVOCATION_CHECK_CACHE_ONLY;
CertFreeCertificateChain(chain_context);
if (!CertGetCertificateChain(
chain_engine,
cert_list.get(),
NULL,
cert_list->hCertStore,
&chain_para,
chain_flags,
NULL,
&chain_context)) {
verify_result->cert_status |= CERT_STATUS_INVALID;
return MapSecurityError(GetLastError());
}
GetCertChainInfo(chain_context, verify_result);
if (chain_context->TrustStatus.dwErrorStatus &
CERT_TRUST_IS_OFFLINE_REVOCATION) {
verify_result->cert_status |= CERT_STATUS_REVOKED;
}
}
ScopedPCCERT_CHAIN_CONTEXT scoped_chain_context(chain_context);
verify_result->cert_status |= MapCertChainErrorStatusToCertStatus(
chain_context->TrustStatus.dwErrorStatus);
if (CertSubjectCommonNameHasNull(cert_handle))
verify_result->cert_status |= CERT_STATUS_INVALID;
std::wstring wstr_hostname = base::ASCIIToWide(hostname);
SSL_EXTRA_CERT_CHAIN_POLICY_PARA extra_policy_para;
memset(&extra_policy_para, 0, sizeof(extra_policy_para));
extra_policy_para.cbSize = sizeof(extra_policy_para);
extra_policy_para.dwAuthType = AUTHTYPE_SERVER;
extra_policy_para.fdwChecks =
0x00001000;
extra_policy_para.pwszServerName =
const_cast<wchar_t*>(wstr_hostname.c_str());
CERT_CHAIN_POLICY_PARA policy_para;
memset(&policy_para, 0, sizeof(policy_para));
policy_para.cbSize = sizeof(policy_para);
policy_para.dwFlags = 0;
policy_para.pvExtraPolicyPara = &extra_policy_para;
CERT_CHAIN_POLICY_STATUS policy_status;
memset(&policy_status, 0, sizeof(policy_status));
policy_status.cbSize = sizeof(policy_status);
if (!CertVerifyCertificateChainPolicy(
CERT_CHAIN_POLICY_SSL,
chain_context,
&policy_para,
&policy_status)) {
return MapSecurityError(GetLastError());
}
if (policy_status.dwError) {
verify_result->cert_status |= MapNetErrorToCertStatus(
MapSecurityError(policy_status.dwError));
}
verify_result->cert_status &= ~CERT_STATUS_NO_REVOCATION_MECHANISM;
if (!cert->VerifyNameMatch(hostname,
&verify_result->common_name_fallback_used)) {
verify_result->cert_status |= CERT_STATUS_COMMON_NAME_INVALID;
}
if (!rev_checking_enabled) {
verify_result->cert_status &= ~CERT_STATUS_UNABLE_TO_CHECK_REVOCATION;
}
AppendPublicKeyHashes(chain_context, &verify_result->public_key_hashes);
verify_result->is_issued_by_known_root = IsIssuedByKnownRoot(chain_context);
if (IsCertStatusError(verify_result->cert_status))
return MapCertStatusToNetError(verify_result->cert_status);
if (ev_policy_oid &&
CheckEV(chain_context, rev_checking_enabled, ev_policy_oid)) {
verify_result->cert_status |= CERT_STATUS_IS_EV;
}
return OK;
}
}