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

Side by Side Diff: net/socket/ssl_client_socket_openssl.cc

Issue 547603002: Certificate Transparency: Code for unpacking EV cert hashes whitelist (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removing unnecessary const Created 6 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « net/socket/ssl_client_socket_nss.cc ('k') | net/ssl/ssl_config_service.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // OpenSSL binding for SSLClientSocket. The class layout and general principle 5 // OpenSSL binding for SSLClientSocket. The class layout and general principle
6 // of operation is derived from SSLClientSocketNSS. 6 // of operation is derived from SSLClientSocketNSS.
7 7
8 #include "net/socket/ssl_client_socket_openssl.h" 8 #include "net/socket/ssl_client_socket_openssl.h"
9 9
10 #include <errno.h> 10 #include <errno.h>
11 #include <openssl/bio.h> 11 #include <openssl/bio.h>
12 #include <openssl/err.h> 12 #include <openssl/err.h>
13 #include <openssl/ssl.h> 13 #include <openssl/ssl.h>
14 14
15 #include "base/bind.h" 15 #include "base/bind.h"
16 #include "base/callback_helpers.h" 16 #include "base/callback_helpers.h"
17 #include "base/environment.h" 17 #include "base/environment.h"
18 #include "base/memory/singleton.h" 18 #include "base/memory/singleton.h"
19 #include "base/metrics/histogram.h" 19 #include "base/metrics/histogram.h"
20 #include "base/strings/string_piece.h" 20 #include "base/strings/string_piece.h"
21 #include "base/synchronization/lock.h" 21 #include "base/synchronization/lock.h"
22 #include "crypto/ec_private_key.h" 22 #include "crypto/ec_private_key.h"
23 #include "crypto/openssl_util.h" 23 #include "crypto/openssl_util.h"
24 #include "crypto/scoped_openssl_types.h" 24 #include "crypto/scoped_openssl_types.h"
25 #include "net/base/net_errors.h" 25 #include "net/base/net_errors.h"
26 #include "net/cert/cert_verifier.h" 26 #include "net/cert/cert_verifier.h"
27 #include "net/cert/ct_ev_whitelist.h"
27 #include "net/cert/ct_verifier.h" 28 #include "net/cert/ct_verifier.h"
28 #include "net/cert/single_request_cert_verifier.h" 29 #include "net/cert/single_request_cert_verifier.h"
29 #include "net/cert/x509_certificate_net_log_param.h" 30 #include "net/cert/x509_certificate_net_log_param.h"
30 #include "net/cert/x509_util_openssl.h" 31 #include "net/cert/x509_util_openssl.h"
31 #include "net/http/transport_security_state.h" 32 #include "net/http/transport_security_state.h"
32 #include "net/socket/ssl_session_cache_openssl.h" 33 #include "net/socket/ssl_session_cache_openssl.h"
33 #include "net/ssl/ssl_cert_request_info.h" 34 #include "net/ssl/ssl_cert_request_info.h"
34 #include "net/ssl/ssl_connection_status_flags.h" 35 #include "net/ssl/ssl_connection_status_flags.h"
35 #include "net/ssl/ssl_info.h" 36 #include "net/ssl/ssl_info.h"
36 37
(...skipping 1062 matching lines...) Expand 10 before | Expand all | Expand 10 after
1099 (result == OK || 1100 (result == OK ||
1100 (IsCertificateError(result) && IsCertStatusMinorError(cert_status))) && 1101 (IsCertificateError(result) && IsCertStatusMinorError(cert_status))) &&
1101 !transport_security_state_->CheckPublicKeyPins( 1102 !transport_security_state_->CheckPublicKeyPins(
1102 host_and_port_.host(), 1103 host_and_port_.host(),
1103 server_cert_verify_result_.is_issued_by_known_root, 1104 server_cert_verify_result_.is_issued_by_known_root,
1104 server_cert_verify_result_.public_key_hashes, 1105 server_cert_verify_result_.public_key_hashes,
1105 &pinning_failure_log_)) { 1106 &pinning_failure_log_)) {
1106 result = ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN; 1107 result = ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN;
1107 } 1108 }
1108 1109
1110 scoped_refptr<ct::EVCertsWhitelist> ev_whitelist =
1111 SSLConfigService::GetEVCertsWhitelist();
1112 if (server_cert_verify_result_.cert_status & CERT_STATUS_IS_EV) {
1113 if (ev_whitelist.get() && ev_whitelist->IsValid()) {
1114 const SHA256HashValue fingerprint(
1115 X509Certificate::CalculateFingerprint256(
1116 server_cert_verify_result_.verified_cert->os_cert_handle()));
1117
1118 UMA_HISTOGRAM_BOOLEAN(
1119 "Net.SSL_EVCertificateInWhitelist",
1120 ev_whitelist->ContainsCertificateHash(
1121 std::string(reinterpret_cast<const char*>(fingerprint.data), 8)));
1122 }
1123 }
1124
1109 if (result == OK) { 1125 if (result == OK) {
1110 // Only check Certificate Transparency if there were no other errors with 1126 // Only check Certificate Transparency if there were no other errors with
1111 // the connection. 1127 // the connection.
1112 VerifyCT(); 1128 VerifyCT();
1113 1129
1114 // TODO(joth): Work out if we need to remember the intermediate CA certs 1130 // TODO(joth): Work out if we need to remember the intermediate CA certs
1115 // when the server sends them to us, and do so here. 1131 // when the server sends them to us, and do so here.
1116 SSLContext::GetInstance()->session_cache()->MarkSSLSessionAsGood(ssl_); 1132 SSLContext::GetInstance()->session_cache()->MarkSSLSessionAsGood(ssl_);
1117 marked_session_as_good_ = true; 1133 marked_session_as_good_ = true;
1118 CheckIfHandshakeFinished(); 1134 CheckIfHandshakeFinished();
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after
1802 ct::SCT_STATUS_LOG_UNKNOWN)); 1818 ct::SCT_STATUS_LOG_UNKNOWN));
1803 } 1819 }
1804 } 1820 }
1805 1821
1806 scoped_refptr<X509Certificate> 1822 scoped_refptr<X509Certificate>
1807 SSLClientSocketOpenSSL::GetUnverifiedServerCertificateChain() const { 1823 SSLClientSocketOpenSSL::GetUnverifiedServerCertificateChain() const {
1808 return server_cert_; 1824 return server_cert_;
1809 } 1825 }
1810 1826
1811 } // namespace net 1827 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/ssl_client_socket_nss.cc ('k') | net/ssl/ssl_config_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698