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

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

Issue 2040513003: Implement Expect-Staple (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Don't report private certificates Created 4 years, 6 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 #include "net/socket/ssl_client_socket_impl.h" 5 #include "net/socket/ssl_client_socket_impl.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <openssl/bio.h> 8 #include <openssl/bio.h>
9 #include <openssl/bytestring.h> 9 #include <openssl/bytestring.h>
10 #include <openssl/err.h> 10 #include <openssl/err.h>
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 78
79 // TLS extension number use for Token Binding. 79 // TLS extension number use for Token Binding.
80 const unsigned int kTbExtNum = 24; 80 const unsigned int kTbExtNum = 24;
81 81
82 // Token Binding ProtocolVersions supported. 82 // Token Binding ProtocolVersions supported.
83 const uint8_t kTbProtocolVersionMajor = 0; 83 const uint8_t kTbProtocolVersionMajor = 0;
84 const uint8_t kTbProtocolVersionMinor = 5; 84 const uint8_t kTbProtocolVersionMinor = 5;
85 const uint8_t kTbMinProtocolVersionMajor = 0; 85 const uint8_t kTbMinProtocolVersionMajor = 0;
86 const uint8_t kTbMinProtocolVersionMinor = 3; 86 const uint8_t kTbMinProtocolVersionMinor = 3;
87 87
88 // Max age for OCSP responses
89 const base::TimeDelta kAgeOneWeek = base::TimeDelta::FromDays(7);
estark 2016/06/15 23:51:47 Unfortunately this constant would have to be dupli
estark 2016/06/15 23:51:47 ditto
estark 2016/06/15 23:51:47 It appears that mozilla::pkix requires responses w
dadrian 2016/06/16 03:27:24 Does QUIC support OCSP stapling? I'm not very fami
dadrian 2016/06/16 03:27:24 1 day seems short, but I have no actual basis for
90
88 bool EVP_MDToPrivateKeyHash(const EVP_MD* md, SSLPrivateKey::Hash* hash) { 91 bool EVP_MDToPrivateKeyHash(const EVP_MD* md, SSLPrivateKey::Hash* hash) {
89 switch (EVP_MD_type(md)) { 92 switch (EVP_MD_type(md)) {
90 case NID_md5_sha1: 93 case NID_md5_sha1:
91 *hash = SSLPrivateKey::Hash::MD5_SHA1; 94 *hash = SSLPrivateKey::Hash::MD5_SHA1;
92 return true; 95 return true;
93 case NID_sha1: 96 case NID_sha1:
94 *hash = SSLPrivateKey::Hash::SHA1; 97 *hash = SSLPrivateKey::Hash::SHA1;
95 return true; 98 return true;
96 case NID_sha256: 99 case NID_sha256:
97 *hash = SSLPrivateKey::Hash::SHA256; 100 *hash = SSLPrivateKey::Hash::SHA256;
(...skipping 1244 matching lines...) Expand 10 before | Expand all | Expand 10 after
1342 result = ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN; 1345 result = ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN;
1343 else 1346 else
1344 pkp_bypassed_ = true; 1347 pkp_bypassed_ = true;
1345 } 1348 }
1346 1349
1347 if (result == OK) { 1350 if (result == OK) {
1348 // Only check Certificate Transparency if there were no other errors with 1351 // Only check Certificate Transparency if there were no other errors with
1349 // the connection. 1352 // the connection.
1350 VerifyCT(); 1353 VerifyCT();
1351 1354
1355 CheckOCSP(*server_cert_verify_result_.verified_cert, *server_cert_,
1356 server_cert_verify_result_.is_issued_by_known_root);
1357
1352 DCHECK(!certificate_verified_); 1358 DCHECK(!certificate_verified_);
1353 certificate_verified_ = true; 1359 certificate_verified_ = true;
1354 MaybeCacheSession(); 1360 MaybeCacheSession();
1355 } 1361 }
1356 1362
1357 completed_connect_ = true; 1363 completed_connect_ = true;
1358 // Exit DoHandshakeLoop and return the result to the caller to Connect. 1364 // Exit DoHandshakeLoop and return the result to the caller to Connect.
1359 DCHECK_EQ(STATE_NONE, next_handshake_state_); 1365 DCHECK_EQ(STATE_NONE, next_handshake_state_);
1360 return result; 1366 return result;
1361 } 1367 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1428 server_cert_verify_result_.cert_status &= ~CERT_STATUS_IS_EV; 1434 server_cert_verify_result_.cert_status &= ~CERT_STATUS_IS_EV;
1429 } 1435 }
1430 } 1436 }
1431 ct_verify_result_.cert_policy_compliance = 1437 ct_verify_result_.cert_policy_compliance =
1432 policy_enforcer_->DoesConformToCertPolicy( 1438 policy_enforcer_->DoesConformToCertPolicy(
1433 server_cert_verify_result_.verified_cert.get(), 1439 server_cert_verify_result_.verified_cert.get(),
1434 ct_verify_result_.verified_scts, net_log_); 1440 ct_verify_result_.verified_scts, net_log_);
1435 } 1441 }
1436 } 1442 }
1437 1443
1444 void SSLClientSocketImpl::CheckOCSP(
1445 const X509Certificate& verified_certificate,
1446 const X509Certificate& unverified_certificate,
1447 bool is_issued_by_known_root) {
1448 base::Time verify_time = base::Time::Now();
1449 transport_security_state_->CheckExpectStaple(
1450 host_and_port_, verified_certificate, unverified_certificate,
1451 is_issued_by_known_root, verify_time, kAgeOneWeek, ocsp_response_);
1452 }
1453
1438 void SSLClientSocketImpl::OnHandshakeIOComplete(int result) { 1454 void SSLClientSocketImpl::OnHandshakeIOComplete(int result) {
1439 int rv = DoHandshakeLoop(result); 1455 int rv = DoHandshakeLoop(result);
1440 if (rv != ERR_IO_PENDING) { 1456 if (rv != ERR_IO_PENDING) {
1441 LogConnectEndEvent(rv); 1457 LogConnectEndEvent(rv);
1442 DoConnectCallback(rv); 1458 DoConnectCallback(rv);
1443 } 1459 }
1444 } 1460 }
1445 1461
1446 void SSLClientSocketImpl::OnSendComplete(int result) { 1462 void SSLClientSocketImpl::OnSendComplete(int result) {
1447 if (next_handshake_state_ == STATE_HANDSHAKE) { 1463 if (next_handshake_state_ == STATE_HANDSHAKE) {
(...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after
2310 if (rv != OK) { 2326 if (rv != OK) {
2311 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_SSL_CONNECT, rv); 2327 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_SSL_CONNECT, rv);
2312 return; 2328 return;
2313 } 2329 }
2314 2330
2315 net_log_.EndEvent(NetLog::TYPE_SSL_CONNECT, 2331 net_log_.EndEvent(NetLog::TYPE_SSL_CONNECT,
2316 base::Bind(&NetLogSSLInfoCallback, base::Unretained(this))); 2332 base::Bind(&NetLogSSLInfoCallback, base::Unretained(this)));
2317 } 2333 }
2318 2334
2319 } // namespace net 2335 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698