Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(167)

Unified Diff: net/base/x509_chain_win.cc

Issue 3146034: Allow the constructed certificate chain to be returned in CertVerifyResult (Closed)
Patch Set: Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/base/x509_chain_nss.cc ('k') | net/data/ssl/certificates/google.full_chain.pem » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/x509_chain_win.cc
diff --git a/net/base/x509_chain_win.cc b/net/base/x509_chain_win.cc
index 49ddc3f6908e4976986ca125c533bb707ac00061..468bfc0b0ba0db4f54072554ab774d55ee8f285c 100644
--- a/net/base/x509_chain_win.cc
+++ b/net/base/x509_chain_win.cc
@@ -257,7 +257,8 @@ bool CertSubjectCommonNameHasNull(PCCERT_CONTEXT cert) {
// Saves some information about the certificate chain chain_context in
// *verify_result. The caller MUST initialize *verify_result before calling
// this function.
-void GetCertChainInfo(PCCERT_CHAIN_CONTEXT chain_context,
+void GetCertChainInfo(int flags,
+ PCCERT_CHAIN_CONTEXT chain_context,
CertVerifyResult* verify_result) {
PCERT_SIMPLE_CHAIN first_chain = chain_context->rgpChain[0];
int num_elements = first_chain->cElement;
@@ -285,6 +286,18 @@ void GetCertChainInfo(PCCERT_CHAIN_CONTEXT chain_context,
verify_result->has_md4 = true;
}
}
+
+ bool return_chain = !!(flags & x509_chain::VERIFY_RETURN_CHAIN);
+ X509Certificate::OSCertHandles intermediates;
+ for (int i = 1; return_chain && i < num_elements; ++i) {
+ PCCERT_CONTEXT cert = element[i]->pCertContext;
+ intermediates.push_back(cert);
+ }
+
+ if (return_chain && num_elements > 0) {
+ verify_result->certificate = X509Certificate::CreateFromHandle(
+ element[0]->pCertContext, intermediates);
+ }
}
///////////////////////////////////////////////////////////////////////////
@@ -486,7 +499,7 @@ int VerifySSLServer(X509Certificate* certificate, const std::string& hostname,
X509Certificate::FreeOSCertListHandle(cert_list);
ScopedCertChainContext scoped_chain_context(chain_context);
- GetCertChainInfo(chain_context, verify_result);
+ GetCertChainInfo(flags, chain_context, verify_result);
verify_result->cert_status |= MapCertChainErrorStatusToCertStatus(
chain_context->TrustStatus.dwErrorStatus);
« no previous file with comments | « net/base/x509_chain_nss.cc ('k') | net/data/ssl/certificates/google.full_chain.pem » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698