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

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: Catching up with base/files change on master Created 6 years, 2 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 unified diff | Download patch
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/openssl_ssl_util.h" 34 #include "net/ssl/openssl_ssl_util.h"
34 #include "net/ssl/ssl_cert_request_info.h" 35 #include "net/ssl/ssl_cert_request_info.h"
35 #include "net/ssl/ssl_connection_status_flags.h" 36 #include "net/ssl/ssl_connection_status_flags.h"
36 #include "net/ssl/ssl_info.h" 37 #include "net/ssl/ssl_info.h"
(...skipping 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 (result == OK || 1092 (result == OK ||
1092 (IsCertificateError(result) && IsCertStatusMinorError(cert_status))) && 1093 (IsCertificateError(result) && IsCertStatusMinorError(cert_status))) &&
1093 !transport_security_state_->CheckPublicKeyPins( 1094 !transport_security_state_->CheckPublicKeyPins(
1094 host_and_port_.host(), 1095 host_and_port_.host(),
1095 server_cert_verify_result_.is_issued_by_known_root, 1096 server_cert_verify_result_.is_issued_by_known_root,
1096 server_cert_verify_result_.public_key_hashes, 1097 server_cert_verify_result_.public_key_hashes,
1097 &pinning_failure_log_)) { 1098 &pinning_failure_log_)) {
1098 result = ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN; 1099 result = ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN;
1099 } 1100 }
1100 1101
1102 scoped_refptr<ct::EVCertsWhitelist> ev_whitelist =
1103 SSLConfigService::GetEVCertsWhitelist();
1104 if (server_cert_verify_result_.cert_status & CERT_STATUS_IS_EV) {
1105 if (ev_whitelist.get() && ev_whitelist->IsValid()) {
1106 const SHA256HashValue fingerprint(
1107 X509Certificate::CalculateFingerprint256(
1108 server_cert_verify_result_.verified_cert->os_cert_handle()));
1109
1110 UMA_HISTOGRAM_BOOLEAN(
1111 "Net.SSL_EVCertificateInWhitelist",
1112 ev_whitelist->ContainsCertificateHash(
1113 std::string(reinterpret_cast<const char*>(fingerprint.data), 8)));
1114 }
1115 }
1116
1101 if (result == OK) { 1117 if (result == OK) {
1102 // Only check Certificate Transparency if there were no other errors with 1118 // Only check Certificate Transparency if there were no other errors with
1103 // the connection. 1119 // the connection.
1104 VerifyCT(); 1120 VerifyCT();
1105 1121
1106 // TODO(joth): Work out if we need to remember the intermediate CA certs 1122 // TODO(joth): Work out if we need to remember the intermediate CA certs
1107 // when the server sends them to us, and do so here. 1123 // when the server sends them to us, and do so here.
1108 SSLContext::GetInstance()->session_cache()->MarkSSLSessionAsGood(ssl_); 1124 SSLContext::GetInstance()->session_cache()->MarkSSLSessionAsGood(ssl_);
1109 marked_session_as_good_ = true; 1125 marked_session_as_good_ = true;
1110 CheckIfHandshakeFinished(); 1126 CheckIfHandshakeFinished();
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after
1766 ct::SCT_STATUS_LOG_UNKNOWN)); 1782 ct::SCT_STATUS_LOG_UNKNOWN));
1767 } 1783 }
1768 } 1784 }
1769 1785
1770 scoped_refptr<X509Certificate> 1786 scoped_refptr<X509Certificate>
1771 SSLClientSocketOpenSSL::GetUnverifiedServerCertificateChain() const { 1787 SSLClientSocketOpenSSL::GetUnverifiedServerCertificateChain() const {
1772 return server_cert_; 1788 return server_cert_;
1773 } 1789 }
1774 1790
1775 } // namespace net 1791 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698