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

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

Issue 761903003: Update from https://crrev.com/306655 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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_openssl.h ('k') | net/socket/ssl_client_socket_pool.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/profiler/scoped_tracker.h" 20 #include "base/profiler/scoped_tracker.h"
21 #include "base/strings/string_piece.h" 21 #include "base/strings/string_piece.h"
22 #include "base/synchronization/lock.h" 22 #include "base/synchronization/lock.h"
23 #include "crypto/ec_private_key.h" 23 #include "crypto/ec_private_key.h"
24 #include "crypto/openssl_util.h" 24 #include "crypto/openssl_util.h"
25 #include "crypto/scoped_openssl_types.h" 25 #include "crypto/scoped_openssl_types.h"
26 #include "net/base/net_errors.h" 26 #include "net/base/net_errors.h"
27 #include "net/cert/cert_policy_enforcer.h"
27 #include "net/cert/cert_verifier.h" 28 #include "net/cert/cert_verifier.h"
28 #include "net/cert/ct_ev_whitelist.h" 29 #include "net/cert/ct_ev_whitelist.h"
29 #include "net/cert/ct_verifier.h" 30 #include "net/cert/ct_verifier.h"
30 #include "net/cert/single_request_cert_verifier.h" 31 #include "net/cert/single_request_cert_verifier.h"
31 #include "net/cert/x509_certificate_net_log_param.h" 32 #include "net/cert/x509_certificate_net_log_param.h"
32 #include "net/cert/x509_util_openssl.h" 33 #include "net/cert/x509_util_openssl.h"
33 #include "net/http/transport_security_state.h" 34 #include "net/http/transport_security_state.h"
34 #include "net/socket/ssl_session_cache_openssl.h" 35 #include "net/socket/ssl_session_cache_openssl.h"
35 #include "net/ssl/ssl_cert_request_info.h" 36 #include "net/ssl/ssl_cert_request_info.h"
36 #include "net/ssl/ssl_connection_status_flags.h" 37 #include "net/ssl/ssl_connection_status_flags.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 typedef crypto::ScopedOpenSSL<X509, X509_free>::Type ScopedX509; 75 typedef crypto::ScopedOpenSSL<X509, X509_free>::Type ScopedX509;
75 typedef crypto::ScopedOpenSSL<STACK_OF(X509), FreeX509Stack>::Type 76 typedef crypto::ScopedOpenSSL<STACK_OF(X509), FreeX509Stack>::Type
76 ScopedX509Stack; 77 ScopedX509Stack;
77 78
78 #if OPENSSL_VERSION_NUMBER < 0x1000103fL 79 #if OPENSSL_VERSION_NUMBER < 0x1000103fL
79 // This method doesn't seem to have made it into the OpenSSL headers. 80 // This method doesn't seem to have made it into the OpenSSL headers.
80 unsigned long SSL_CIPHER_get_id(const SSL_CIPHER* cipher) { return cipher->id; } 81 unsigned long SSL_CIPHER_get_id(const SSL_CIPHER* cipher) { return cipher->id; }
81 #endif 82 #endif
82 83
83 // Used for encoding the |connection_status| field of an SSLInfo object. 84 // Used for encoding the |connection_status| field of an SSLInfo object.
84 int EncodeSSLConnectionStatus(int cipher_suite, 85 int EncodeSSLConnectionStatus(uint16 cipher_suite,
85 int compression, 86 int compression,
86 int version) { 87 int version) {
87 return ((cipher_suite & SSL_CONNECTION_CIPHERSUITE_MASK) << 88 return cipher_suite |
88 SSL_CONNECTION_CIPHERSUITE_SHIFT) |
89 ((compression & SSL_CONNECTION_COMPRESSION_MASK) << 89 ((compression & SSL_CONNECTION_COMPRESSION_MASK) <<
90 SSL_CONNECTION_COMPRESSION_SHIFT) | 90 SSL_CONNECTION_COMPRESSION_SHIFT) |
91 ((version & SSL_CONNECTION_VERSION_MASK) << 91 ((version & SSL_CONNECTION_VERSION_MASK) <<
92 SSL_CONNECTION_VERSION_SHIFT); 92 SSL_CONNECTION_VERSION_SHIFT);
93 } 93 }
94 94
95 // Returns the net SSL version number (see ssl_connection_status_flags.h) for 95 // Returns the net SSL version number (see ssl_connection_status_flags.h) for
96 // this SSL connection. 96 // this SSL connection.
97 int GetNetSSLVersion(SSL* ssl) { 97 int GetNetSSLVersion(SSL* ssl) {
98 switch (SSL_version(ssl)) { 98 switch (SSL_version(ssl)) {
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 60 * 60, // timeout_seconds 338 60 * 60, // timeout_seconds
339 }; 339 };
340 340
341 // static 341 // static
342 void SSLClientSocket::ClearSessionCache() { 342 void SSLClientSocket::ClearSessionCache() {
343 SSLClientSocketOpenSSL::SSLContext* context = 343 SSLClientSocketOpenSSL::SSLContext* context =
344 SSLClientSocketOpenSSL::SSLContext::GetInstance(); 344 SSLClientSocketOpenSSL::SSLContext::GetInstance();
345 context->session_cache()->Flush(); 345 context->session_cache()->Flush();
346 } 346 }
347 347
348 // static
349 uint16 SSLClientSocket::GetMaxSupportedSSLVersion() {
350 return SSL_PROTOCOL_VERSION_TLS1_2;
351 }
352
348 SSLClientSocketOpenSSL::SSLClientSocketOpenSSL( 353 SSLClientSocketOpenSSL::SSLClientSocketOpenSSL(
349 scoped_ptr<ClientSocketHandle> transport_socket, 354 scoped_ptr<ClientSocketHandle> transport_socket,
350 const HostPortPair& host_and_port, 355 const HostPortPair& host_and_port,
351 const SSLConfig& ssl_config, 356 const SSLConfig& ssl_config,
352 const SSLClientSocketContext& context) 357 const SSLClientSocketContext& context)
353 : transport_send_busy_(false), 358 : transport_send_busy_(false),
354 transport_recv_busy_(false), 359 transport_recv_busy_(false),
355 pending_read_error_(kNoPendingReadResult), 360 pending_read_error_(kNoPendingReadResult),
356 pending_read_ssl_error_(SSL_ERROR_NONE), 361 pending_read_ssl_error_(SSL_ERROR_NONE),
357 transport_read_error_(OK), 362 transport_read_error_(OK),
(...skipping 11 matching lines...) Expand all
369 host_and_port_(host_and_port), 374 host_and_port_(host_and_port),
370 ssl_config_(ssl_config), 375 ssl_config_(ssl_config),
371 ssl_session_cache_shard_(context.ssl_session_cache_shard), 376 ssl_session_cache_shard_(context.ssl_session_cache_shard),
372 trying_cached_session_(false), 377 trying_cached_session_(false),
373 next_handshake_state_(STATE_NONE), 378 next_handshake_state_(STATE_NONE),
374 npn_status_(kNextProtoUnsupported), 379 npn_status_(kNextProtoUnsupported),
375 channel_id_xtn_negotiated_(false), 380 channel_id_xtn_negotiated_(false),
376 handshake_succeeded_(false), 381 handshake_succeeded_(false),
377 marked_session_as_good_(false), 382 marked_session_as_good_(false),
378 transport_security_state_(context.transport_security_state), 383 transport_security_state_(context.transport_security_state),
384 policy_enforcer_(context.cert_policy_enforcer),
379 net_log_(transport_->socket()->NetLog()), 385 net_log_(transport_->socket()->NetLog()),
380 weak_factory_(this) { 386 weak_factory_(this) {
381 } 387 }
382 388
383 SSLClientSocketOpenSSL::~SSLClientSocketOpenSSL() { 389 SSLClientSocketOpenSSL::~SSLClientSocketOpenSSL() {
384 Disconnect(); 390 Disconnect();
385 } 391 }
386 392
387 std::string SSLClientSocketOpenSSL::GetSessionCacheKey() const { 393 std::string SSLClientSocketOpenSSL::GetSessionCacheKey() const {
388 std::string result = host_and_port_.ToString(); 394 std::string result = host_and_port_.ToString();
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 ssl_info->channel_id_sent = WasChannelIDSent(); 624 ssl_info->channel_id_sent = WasChannelIDSent();
619 ssl_info->pinning_failure_log = pinning_failure_log_; 625 ssl_info->pinning_failure_log = pinning_failure_log_;
620 626
621 AddSCTInfoToSSLInfo(ssl_info); 627 AddSCTInfoToSSLInfo(ssl_info);
622 628
623 const SSL_CIPHER* cipher = SSL_get_current_cipher(ssl_); 629 const SSL_CIPHER* cipher = SSL_get_current_cipher(ssl_);
624 CHECK(cipher); 630 CHECK(cipher);
625 ssl_info->security_bits = SSL_CIPHER_get_bits(cipher, NULL); 631 ssl_info->security_bits = SSL_CIPHER_get_bits(cipher, NULL);
626 632
627 ssl_info->connection_status = EncodeSSLConnectionStatus( 633 ssl_info->connection_status = EncodeSSLConnectionStatus(
628 SSL_CIPHER_get_id(cipher), 0 /* no compression */, 634 static_cast<uint16>(SSL_CIPHER_get_id(cipher)), 0 /* no compression */,
629 GetNetSSLVersion(ssl_)); 635 GetNetSSLVersion(ssl_));
630 636
631 if (!SSL_get_secure_renegotiation_support(ssl_)) 637 if (!SSL_get_secure_renegotiation_support(ssl_))
632 ssl_info->connection_status |= SSL_CONNECTION_NO_RENEGOTIATION_EXTENSION; 638 ssl_info->connection_status |= SSL_CONNECTION_NO_RENEGOTIATION_EXTENSION;
633 639
634 if (ssl_config_.version_fallback) 640 if (ssl_config_.version_fallback)
635 ssl_info->connection_status |= SSL_CONNECTION_VERSION_FALLBACK; 641 ssl_info->connection_status |= SSL_CONNECTION_VERSION_FALLBACK;
636 642
637 ssl_info->handshake_type = SSL_session_reused(ssl_) ? 643 ssl_info->handshake_type = SSL_session_reused(ssl_) ?
638 SSLInfo::HANDSHAKE_RESUME : SSLInfo::HANDSHAKE_FULL; 644 SSLInfo::HANDSHAKE_RESUME : SSLInfo::HANDSHAKE_FULL;
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 // See SSLConfig::disabled_cipher_suites for description of the suites 787 // See SSLConfig::disabled_cipher_suites for description of the suites
782 // disabled by default. Note that !SHA256 and !SHA384 only remove HMAC-SHA256 788 // disabled by default. Note that !SHA256 and !SHA384 only remove HMAC-SHA256
783 // and HMAC-SHA384 cipher suites, not GCM cipher suites with SHA256 or SHA384 789 // and HMAC-SHA384 cipher suites, not GCM cipher suites with SHA256 or SHA384
784 // as the handshake hash. 790 // as the handshake hash.
785 std::string command("DEFAULT:!NULL:!aNULL:!IDEA:!FZA:!SRP:!SHA256:!SHA384:" 791 std::string command("DEFAULT:!NULL:!aNULL:!IDEA:!FZA:!SRP:!SHA256:!SHA384:"
786 "!aECDH:!AESGCM+AES256"); 792 "!aECDH:!AESGCM+AES256");
787 // Walk through all the installed ciphers, seeing if any need to be 793 // Walk through all the installed ciphers, seeing if any need to be
788 // appended to the cipher removal |command|. 794 // appended to the cipher removal |command|.
789 for (size_t i = 0; i < sk_SSL_CIPHER_num(ciphers); ++i) { 795 for (size_t i = 0; i < sk_SSL_CIPHER_num(ciphers); ++i) {
790 const SSL_CIPHER* cipher = sk_SSL_CIPHER_value(ciphers, i); 796 const SSL_CIPHER* cipher = sk_SSL_CIPHER_value(ciphers, i);
791 const uint16 id = SSL_CIPHER_get_id(cipher); 797 const uint16 id = static_cast<uint16>(SSL_CIPHER_get_id(cipher));
792 // Remove any ciphers with a strength of less than 80 bits. Note the NSS 798 // Remove any ciphers with a strength of less than 80 bits. Note the NSS
793 // implementation uses "effective" bits here but OpenSSL does not provide 799 // implementation uses "effective" bits here but OpenSSL does not provide
794 // this detail. This only impacts Triple DES: reports 112 vs. 168 bits, 800 // this detail. This only impacts Triple DES: reports 112 vs. 168 bits,
795 // both of which are greater than 80 anyway. 801 // both of which are greater than 80 anyway.
796 bool disable = SSL_CIPHER_get_bits(cipher, NULL) < 80; 802 bool disable = SSL_CIPHER_get_bits(cipher, NULL) < 80;
797 if (!disable) { 803 if (!disable) {
798 disable = std::find(ssl_config_.disabled_cipher_suites.begin(), 804 disable = std::find(ssl_config_.disabled_cipher_suites.begin(),
799 ssl_config_.disabled_cipher_suites.end(), id) != 805 ssl_config_.disabled_cipher_suites.end(), id) !=
800 ssl_config_.disabled_cipher_suites.end(); 806 ssl_config_.disabled_cipher_suites.end();
801 } 807 }
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
953 } 959 }
954 960
955 RecordChannelIDSupport(channel_id_service_, 961 RecordChannelIDSupport(channel_id_service_,
956 channel_id_xtn_negotiated_, 962 channel_id_xtn_negotiated_,
957 ssl_config_.channel_id_enabled, 963 ssl_config_.channel_id_enabled,
958 crypto::ECPrivateKey::IsSupported()); 964 crypto::ECPrivateKey::IsSupported());
959 965
960 // Only record OCSP histograms if OCSP was requested. 966 // Only record OCSP histograms if OCSP was requested.
961 if (ssl_config_.signed_cert_timestamps_enabled || 967 if (ssl_config_.signed_cert_timestamps_enabled ||
962 IsOCSPStaplingSupported()) { 968 IsOCSPStaplingSupported()) {
963 uint8_t* ocsp_response; 969 const uint8_t* ocsp_response;
964 size_t ocsp_response_len; 970 size_t ocsp_response_len;
965 SSL_get0_ocsp_response(ssl_, &ocsp_response, &ocsp_response_len); 971 SSL_get0_ocsp_response(ssl_, &ocsp_response, &ocsp_response_len);
966 972
967 set_stapled_ocsp_response_received(ocsp_response_len != 0); 973 set_stapled_ocsp_response_received(ocsp_response_len != 0);
968 UMA_HISTOGRAM_BOOLEAN("Net.OCSPResponseStapled", ocsp_response_len != 0); 974 UMA_HISTOGRAM_BOOLEAN("Net.OCSPResponseStapled", ocsp_response_len != 0);
969 } 975 }
970 976
971 uint8_t* sct_list; 977 const uint8_t* sct_list;
972 size_t sct_list_len; 978 size_t sct_list_len;
973 SSL_get0_signed_cert_timestamp_list(ssl_, &sct_list, &sct_list_len); 979 SSL_get0_signed_cert_timestamp_list(ssl_, &sct_list, &sct_list_len);
974 set_signed_cert_timestamps_received(sct_list_len != 0); 980 set_signed_cert_timestamps_received(sct_list_len != 0);
975 981
976 // Verify the certificate. 982 // Verify the certificate.
977 UpdateServerCert(); 983 UpdateServerCert();
978 GotoState(STATE_VERIFY_CERT); 984 GotoState(STATE_VERIFY_CERT);
979 } else { 985 } else {
980 int ssl_error = SSL_get_error(ssl_, rv); 986 int ssl_error = SSL_get_error(ssl_, rv);
981 987
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
1133 (result == OK || 1139 (result == OK ||
1134 (IsCertificateError(result) && IsCertStatusMinorError(cert_status))) && 1140 (IsCertificateError(result) && IsCertStatusMinorError(cert_status))) &&
1135 !transport_security_state_->CheckPublicKeyPins( 1141 !transport_security_state_->CheckPublicKeyPins(
1136 host_and_port_.host(), 1142 host_and_port_.host(),
1137 server_cert_verify_result_.is_issued_by_known_root, 1143 server_cert_verify_result_.is_issued_by_known_root,
1138 server_cert_verify_result_.public_key_hashes, 1144 server_cert_verify_result_.public_key_hashes,
1139 &pinning_failure_log_)) { 1145 &pinning_failure_log_)) {
1140 result = ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN; 1146 result = ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN;
1141 } 1147 }
1142 1148
1143 scoped_refptr<ct::EVCertsWhitelist> ev_whitelist =
1144 SSLConfigService::GetEVCertsWhitelist();
1145 if (server_cert_verify_result_.cert_status & CERT_STATUS_IS_EV) {
1146 if (ev_whitelist.get() && ev_whitelist->IsValid()) {
1147 const SHA256HashValue fingerprint(
1148 X509Certificate::CalculateFingerprint256(
1149 server_cert_verify_result_.verified_cert->os_cert_handle()));
1150
1151 UMA_HISTOGRAM_BOOLEAN(
1152 "Net.SSL_EVCertificateInWhitelist",
1153 ev_whitelist->ContainsCertificateHash(
1154 std::string(reinterpret_cast<const char*>(fingerprint.data), 8)));
1155 }
1156 }
1157
1158 if (result == OK) { 1149 if (result == OK) {
1159 // Only check Certificate Transparency if there were no other errors with 1150 // Only check Certificate Transparency if there were no other errors with
1160 // the connection. 1151 // the connection.
1161 VerifyCT(); 1152 VerifyCT();
1162 1153
1163 // TODO(joth): Work out if we need to remember the intermediate CA certs 1154 // TODO(joth): Work out if we need to remember the intermediate CA certs
1164 // when the server sends them to us, and do so here. 1155 // when the server sends them to us, and do so here.
1165 SSLContext::GetInstance()->session_cache()->MarkSSLSessionAsGood(ssl_); 1156 SSLContext::GetInstance()->session_cache()->MarkSSLSessionAsGood(ssl_);
1166 marked_session_as_good_ = true; 1157 marked_session_as_good_ = true;
1167 CheckIfHandshakeFinished(); 1158 CheckIfHandshakeFinished();
(...skipping 26 matching lines...) Expand all
1194 if (server_cert_.get()) { 1185 if (server_cert_.get()) {
1195 net_log_.AddEvent( 1186 net_log_.AddEvent(
1196 NetLog::TYPE_SSL_CERTIFICATES_RECEIVED, 1187 NetLog::TYPE_SSL_CERTIFICATES_RECEIVED,
1197 base::Bind(&NetLogX509CertificateCallback, 1188 base::Bind(&NetLogX509CertificateCallback,
1198 base::Unretained(server_cert_.get()))); 1189 base::Unretained(server_cert_.get())));
1199 1190
1200 // TODO(rsleevi): Plumb an OCSP response into the Mac system library and 1191 // TODO(rsleevi): Plumb an OCSP response into the Mac system library and
1201 // update IsOCSPStaplingSupported for Mac. https://crbug.com/430714 1192 // update IsOCSPStaplingSupported for Mac. https://crbug.com/430714
1202 if (IsOCSPStaplingSupported()) { 1193 if (IsOCSPStaplingSupported()) {
1203 #if defined(OS_WIN) 1194 #if defined(OS_WIN)
1204 uint8_t* ocsp_response_raw; 1195 const uint8_t* ocsp_response_raw;
1205 size_t ocsp_response_len; 1196 size_t ocsp_response_len;
1206 SSL_get0_ocsp_response(ssl_, &ocsp_response_raw, &ocsp_response_len); 1197 SSL_get0_ocsp_response(ssl_, &ocsp_response_raw, &ocsp_response_len);
1207 1198
1208 CRYPT_DATA_BLOB ocsp_response_blob; 1199 CRYPT_DATA_BLOB ocsp_response_blob;
1209 ocsp_response_blob.cbData = ocsp_response_len; 1200 ocsp_response_blob.cbData = ocsp_response_len;
1210 ocsp_response_blob.pbData = ocsp_response_raw; 1201 ocsp_response_blob.pbData = const_cast<BYTE*>(ocsp_response_raw);
1211 BOOL ok = CertSetCertificateContextProperty( 1202 BOOL ok = CertSetCertificateContextProperty(
1212 server_cert_->os_cert_handle(), 1203 server_cert_->os_cert_handle(),
1213 CERT_OCSP_RESPONSE_PROP_ID, 1204 CERT_OCSP_RESPONSE_PROP_ID,
1214 CERT_SET_PROPERTY_IGNORE_PERSIST_ERROR_FLAG, 1205 CERT_SET_PROPERTY_IGNORE_PERSIST_ERROR_FLAG,
1215 &ocsp_response_blob); 1206 &ocsp_response_blob);
1216 if (!ok) { 1207 if (!ok) {
1217 VLOG(1) << "Failed to set OCSP response property: " 1208 VLOG(1) << "Failed to set OCSP response property: "
1218 << GetLastError(); 1209 << GetLastError();
1219 } 1210 }
1220 #else 1211 #else
1221 NOTREACHED(); 1212 NOTREACHED();
1222 #endif 1213 #endif
1223 } 1214 }
1224 } 1215 }
1225 } 1216 }
1226 1217
1227 void SSLClientSocketOpenSSL::VerifyCT() { 1218 void SSLClientSocketOpenSSL::VerifyCT() {
1228 if (!cert_transparency_verifier_) 1219 if (!cert_transparency_verifier_)
1229 return; 1220 return;
1230 1221
1231 uint8_t* ocsp_response_raw; 1222 const uint8_t* ocsp_response_raw;
1232 size_t ocsp_response_len; 1223 size_t ocsp_response_len;
1233 SSL_get0_ocsp_response(ssl_, &ocsp_response_raw, &ocsp_response_len); 1224 SSL_get0_ocsp_response(ssl_, &ocsp_response_raw, &ocsp_response_len);
1234 std::string ocsp_response; 1225 std::string ocsp_response;
1235 if (ocsp_response_len > 0) { 1226 if (ocsp_response_len > 0) {
1236 ocsp_response.assign(reinterpret_cast<const char*>(ocsp_response_raw), 1227 ocsp_response.assign(reinterpret_cast<const char*>(ocsp_response_raw),
1237 ocsp_response_len); 1228 ocsp_response_len);
1238 } 1229 }
1239 1230
1240 uint8_t* sct_list_raw; 1231 const uint8_t* sct_list_raw;
1241 size_t sct_list_len; 1232 size_t sct_list_len;
1242 SSL_get0_signed_cert_timestamp_list(ssl_, &sct_list_raw, &sct_list_len); 1233 SSL_get0_signed_cert_timestamp_list(ssl_, &sct_list_raw, &sct_list_len);
1243 std::string sct_list; 1234 std::string sct_list;
1244 if (sct_list_len > 0) 1235 if (sct_list_len > 0)
1245 sct_list.assign(reinterpret_cast<const char*>(sct_list_raw), sct_list_len); 1236 sct_list.assign(reinterpret_cast<const char*>(sct_list_raw), sct_list_len);
1246 1237
1247 // Note that this is a completely synchronous operation: The CT Log Verifier 1238 // Note that this is a completely synchronous operation: The CT Log Verifier
1248 // gets all the data it needs for SCT verification and does not do any 1239 // gets all the data it needs for SCT verification and does not do any
1249 // external communication. 1240 // external communication.
1250 int result = cert_transparency_verifier_->Verify( 1241 cert_transparency_verifier_->Verify(
1251 server_cert_verify_result_.verified_cert.get(), 1242 server_cert_verify_result_.verified_cert.get(), ocsp_response, sct_list,
1252 ocsp_response, sct_list, &ct_verify_result_, net_log_); 1243 &ct_verify_result_, net_log_);
1253 1244
1254 VLOG(1) << "CT Verification complete: result " << result 1245 if (!policy_enforcer_) {
1255 << " Invalid scts: " << ct_verify_result_.invalid_scts.size() 1246 server_cert_verify_result_.cert_status &= ~CERT_STATUS_IS_EV;
1256 << " Verified scts: " << ct_verify_result_.verified_scts.size() 1247 } else {
1257 << " scts from unknown logs: " 1248 if (server_cert_verify_result_.cert_status & CERT_STATUS_IS_EV) {
1258 << ct_verify_result_.unknown_logs_scts.size(); 1249 scoped_refptr<ct::EVCertsWhitelist> ev_whitelist =
1250 SSLConfigService::GetEVCertsWhitelist();
1251 if (!policy_enforcer_->DoesConformToCTEVPolicy(
1252 server_cert_verify_result_.verified_cert.get(),
1253 ev_whitelist.get(), ct_verify_result_)) {
1254 // TODO(eranm): Log via the BoundNetLog, see crbug.com/437766
1255 VLOG(1) << "EV certificate for "
1256 << server_cert_verify_result_.verified_cert->subject()
1257 .GetDisplayName()
1258 << " does not conform to CT policy, removing EV status.";
1259 server_cert_verify_result_.cert_status &= ~CERT_STATUS_IS_EV;
1260 }
1261 }
1262 }
1259 } 1263 }
1260 1264
1261 void SSLClientSocketOpenSSL::OnHandshakeIOComplete(int result) { 1265 void SSLClientSocketOpenSSL::OnHandshakeIOComplete(int result) {
1262 int rv = DoHandshakeLoop(result); 1266 int rv = DoHandshakeLoop(result);
1263 if (rv != ERR_IO_PENDING) { 1267 if (rv != ERR_IO_PENDING) {
1264 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_SSL_CONNECT, rv); 1268 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_SSL_CONNECT, rv);
1265 DoConnectCallback(rv); 1269 DoConnectCallback(rv);
1266 } 1270 }
1267 } 1271 }
1268 1272
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
1899 ct::SCT_STATUS_LOG_UNKNOWN)); 1903 ct::SCT_STATUS_LOG_UNKNOWN));
1900 } 1904 }
1901 } 1905 }
1902 1906
1903 scoped_refptr<X509Certificate> 1907 scoped_refptr<X509Certificate>
1904 SSLClientSocketOpenSSL::GetUnverifiedServerCertificateChain() const { 1908 SSLClientSocketOpenSSL::GetUnverifiedServerCertificateChain() const {
1905 return server_cert_; 1909 return server_cert_;
1906 } 1910 }
1907 1911
1908 } // namespace net 1912 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/ssl_client_socket_openssl.h ('k') | net/socket/ssl_client_socket_pool.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698