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

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

Issue 2728823002: Remove redundant 3-SHAKE mitigation. (Closed)
Patch Set: typo Created 3 years, 9 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 <string.h> 8 #include <string.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 "SSLLegacyECDSACiphers", base::FEATURE_DISABLED_BY_DEFAULT}; 230 "SSLLegacyECDSACiphers", base::FEATURE_DISABLED_BY_DEFAULT};
231 231
232 bool AreLegacyECDSACiphersEnabled() { 232 bool AreLegacyECDSACiphersEnabled() {
233 return base::FeatureList::IsEnabled(kLegacyECDSACiphersFeature); 233 return base::FeatureList::IsEnabled(kLegacyECDSACiphersFeature);
234 } 234 }
235 #endif 235 #endif
236 236
237 const base::Feature kShortRecordHeaderFeature{ 237 const base::Feature kShortRecordHeaderFeature{
238 "SSLShortRecordHeader", base::FEATURE_DISABLED_BY_DEFAULT}; 238 "SSLShortRecordHeader", base::FEATURE_DISABLED_BY_DEFAULT};
239 239
240 scoped_refptr<X509Certificate> OSChainFromOpenSSL(STACK_OF(X509) *
241 openssl_chain) {
242 if (sk_X509_num(openssl_chain) == 0) {
243 NOTREACHED();
244 return nullptr;
245 }
246
247 #if defined(USE_OPENSSL_CERTS)
248 // When OSCertHandle is typedef'ed to X509, this implementation does a short
249 // cut to avoid converting back and forth between DER and the X509 struct.
250 X509Certificate::OSCertHandles intermediates;
251 for (size_t i = 1; i < sk_X509_num(openssl_chain); ++i) {
252 X509* cert = sk_X509_value(openssl_chain, i);
253 DCHECK(cert->buf);
254 intermediates.push_back(cert);
255 }
256
257 X509* leaf = sk_X509_value(openssl_chain, 0);
258 DCHECK(leaf->buf);
259 return X509Certificate::CreateFromHandle(leaf, intermediates);
260 #else
261 // Convert the certificate chains to a platform certificate handle.
262 std::vector<base::StringPiece> der_chain;
263 der_chain.reserve(sk_X509_num(openssl_chain));
264 for (size_t i = 0; i < sk_X509_num(openssl_chain); ++i) {
265 X509* cert = sk_X509_value(openssl_chain, i);
266 DCHECK(cert->buf);
267 base::StringPiece der;
268 if (!x509_util::GetDER(cert, &der))
269 return nullptr;
270 der_chain.push_back(der);
271 }
272 return X509Certificate::CreateFromDERCertChain(der_chain);
273 #endif
274 }
275
240 } // namespace 276 } // namespace
241 277
242 class SSLClientSocketImpl::SSLContext { 278 class SSLClientSocketImpl::SSLContext {
243 public: 279 public:
244 static SSLContext* GetInstance() { 280 static SSLContext* GetInstance() {
245 return base::Singleton<SSLContext, 281 return base::Singleton<SSLContext,
246 base::LeakySingletonTraits<SSLContext>>::get(); 282 base::LeakySingletonTraits<SSLContext>>::get();
247 } 283 }
248 SSL_CTX* ssl_ctx() { return ssl_ctx_.get(); } 284 SSL_CTX* ssl_ctx() { return ssl_ctx_.get(); }
249 SSLClientSessionCache* session_cache() { return &session_cache_; } 285 SSLClientSessionCache* session_cache() { return &session_cache_; }
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 const SSL_PRIVATE_KEY_METHOD 457 const SSL_PRIVATE_KEY_METHOD
422 SSLClientSocketImpl::SSLContext::kPrivateKeyMethod = { 458 SSLClientSocketImpl::SSLContext::kPrivateKeyMethod = {
423 &SSLClientSocketImpl::SSLContext::PrivateKeyTypeCallback, 459 &SSLClientSocketImpl::SSLContext::PrivateKeyTypeCallback,
424 &SSLClientSocketImpl::SSLContext::PrivateKeyMaxSignatureLenCallback, 460 &SSLClientSocketImpl::SSLContext::PrivateKeyMaxSignatureLenCallback,
425 nullptr /* sign */, 461 nullptr /* sign */,
426 &SSLClientSocketImpl::SSLContext::PrivateKeySignDigestCallback, 462 &SSLClientSocketImpl::SSLContext::PrivateKeySignDigestCallback,
427 nullptr /* decrypt */, 463 nullptr /* decrypt */,
428 &SSLClientSocketImpl::SSLContext::PrivateKeyCompleteCallback, 464 &SSLClientSocketImpl::SSLContext::PrivateKeyCompleteCallback,
429 }; 465 };
430 466
431 // PeerCertificateChain is a helper object which extracts the certificate
432 // chain, as given by the server, from an OpenSSL socket and performs the needed
433 // resource management. The first element of the chain is the leaf certificate
434 // and the other elements are in the order given by the server.
435 class SSLClientSocketImpl::PeerCertificateChain {
436 public:
437 explicit PeerCertificateChain(STACK_OF(X509) * chain) { Reset(chain); }
438 PeerCertificateChain(const PeerCertificateChain& other) { *this = other; }
439 ~PeerCertificateChain() {}
440 PeerCertificateChain& operator=(const PeerCertificateChain& other);
441
442 // Resets the PeerCertificateChain to the set of certificates in|chain|,
443 // which may be NULL, indicating to empty the store certificates.
444 // Note: If an error occurs, such as being unable to parse the certificates,
445 // this will behave as if Reset(NULL) was called.
446 void Reset(STACK_OF(X509) * chain);
447
448 // Note that when USE_OPENSSL_CERTS is defined, OSCertHandle is X509*
449 scoped_refptr<X509Certificate> AsOSChain() const;
450
451 size_t size() const {
452 if (!openssl_chain_.get())
453 return 0;
454 return sk_X509_num(openssl_chain_.get());
455 }
456
457 bool empty() const { return size() == 0; }
458
459 X509* Get(size_t index) const {
460 DCHECK_LT(index, size());
461 return sk_X509_value(openssl_chain_.get(), index);
462 }
463
464 private:
465 bssl::UniquePtr<STACK_OF(X509)> openssl_chain_;
466 };
467
468 SSLClientSocketImpl::PeerCertificateChain&
469 SSLClientSocketImpl::PeerCertificateChain::operator=(
470 const PeerCertificateChain& other) {
471 if (this == &other)
472 return *this;
473
474 openssl_chain_.reset(X509_chain_up_ref(other.openssl_chain_.get()));
475 return *this;
476 }
477
478 void SSLClientSocketImpl::PeerCertificateChain::Reset(STACK_OF(X509) * chain) {
479 openssl_chain_.reset(chain ? X509_chain_up_ref(chain) : NULL);
480 }
481
482 scoped_refptr<X509Certificate>
483 SSLClientSocketImpl::PeerCertificateChain::AsOSChain() const {
484 #if defined(USE_OPENSSL_CERTS)
485 // When OSCertHandle is typedef'ed to X509, this implementation does a short
486 // cut to avoid converting back and forth between DER and the X509 struct.
487 X509Certificate::OSCertHandles intermediates;
488 for (size_t i = 1; i < sk_X509_num(openssl_chain_.get()); ++i) {
489 X509* cert = sk_X509_value(openssl_chain_.get(), i);
490 DCHECK(cert->buf);
491 intermediates.push_back(cert);
492 }
493
494 X509* leaf = sk_X509_value(openssl_chain_.get(), 0);
495 DCHECK(leaf->buf);
496 return X509Certificate::CreateFromHandle(leaf, intermediates);
497 #else
498 // Convert the certificate chains to a platform certificate handle.
499 std::vector<base::StringPiece> der_chain;
500 der_chain.reserve(sk_X509_num(openssl_chain_.get()));
501 for (size_t i = 0; i < sk_X509_num(openssl_chain_.get()); ++i) {
502 X509* cert = sk_X509_value(openssl_chain_.get(), i);
503 DCHECK(cert->buf);
504 base::StringPiece der;
505 if (!x509_util::GetDER(cert, &der))
506 return nullptr;
507 der_chain.push_back(der);
508 }
509 return X509Certificate::CreateFromDERCertChain(der_chain);
510 #endif
511 }
512
513 // static 467 // static
514 void SSLClientSocket::ClearSessionCache() { 468 void SSLClientSocket::ClearSessionCache() {
515 SSLClientSocketImpl::SSLContext* context = 469 SSLClientSocketImpl::SSLContext* context =
516 SSLClientSocketImpl::SSLContext::GetInstance(); 470 SSLClientSocketImpl::SSLContext::GetInstance();
517 context->session_cache()->Flush(); 471 context->session_cache()->Flush();
518 } 472 }
519 473
520 SSLClientSocketImpl::SSLClientSocketImpl( 474 SSLClientSocketImpl::SSLClientSocketImpl(
521 std::unique_ptr<ClientSocketHandle> transport_socket, 475 std::unique_ptr<ClientSocketHandle> transport_socket,
522 const HostPortPair& host_and_port, 476 const HostPortPair& host_and_port,
523 const SSLConfig& ssl_config, 477 const SSLConfig& ssl_config,
524 const SSLClientSocketContext& context) 478 const SSLClientSocketContext& context)
525 : pending_read_error_(kNoPendingResult), 479 : pending_read_error_(kNoPendingResult),
526 pending_read_ssl_error_(SSL_ERROR_NONE), 480 pending_read_ssl_error_(SSL_ERROR_NONE),
527 server_cert_chain_(new PeerCertificateChain(NULL)),
528 completed_connect_(false), 481 completed_connect_(false),
529 was_ever_used_(false), 482 was_ever_used_(false),
530 cert_verifier_(context.cert_verifier), 483 cert_verifier_(context.cert_verifier),
531 cert_transparency_verifier_(context.cert_transparency_verifier), 484 cert_transparency_verifier_(context.cert_transparency_verifier),
532 channel_id_service_(context.channel_id_service), 485 channel_id_service_(context.channel_id_service),
533 tb_was_negotiated_(false), 486 tb_was_negotiated_(false),
534 tb_negotiated_param_(TB_PARAM_ECDSAP256), 487 tb_negotiated_param_(TB_PARAM_ECDSAP256),
535 tb_signature_map_(10), 488 tb_signature_map_(10),
536 transport_(std::move(transport_socket)), 489 transport_(std::move(transport_socket)),
537 host_and_port_(host_and_port), 490 host_and_port_(host_and_port),
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 bool SSLClientSocketImpl::WasAlpnNegotiated() const { 738 bool SSLClientSocketImpl::WasAlpnNegotiated() const {
786 return negotiated_protocol_ != kProtoUnknown; 739 return negotiated_protocol_ != kProtoUnknown;
787 } 740 }
788 741
789 NextProto SSLClientSocketImpl::GetNegotiatedProtocol() const { 742 NextProto SSLClientSocketImpl::GetNegotiatedProtocol() const {
790 return negotiated_protocol_; 743 return negotiated_protocol_;
791 } 744 }
792 745
793 bool SSLClientSocketImpl::GetSSLInfo(SSLInfo* ssl_info) { 746 bool SSLClientSocketImpl::GetSSLInfo(SSLInfo* ssl_info) {
794 ssl_info->Reset(); 747 ssl_info->Reset();
795 if (server_cert_chain_->empty()) 748 if (!server_cert_)
796 return false; 749 return false;
797 750
798 ssl_info->cert = server_cert_verify_result_.verified_cert; 751 ssl_info->cert = server_cert_verify_result_.verified_cert;
799 ssl_info->unverified_cert = server_cert_; 752 ssl_info->unverified_cert = server_cert_;
800 ssl_info->cert_status = server_cert_verify_result_.cert_status; 753 ssl_info->cert_status = server_cert_verify_result_.cert_status;
801 ssl_info->is_issued_by_known_root = 754 ssl_info->is_issued_by_known_root =
802 server_cert_verify_result_.is_issued_by_known_root; 755 server_cert_verify_result_.is_issued_by_known_root;
803 ssl_info->pkp_bypassed = pkp_bypassed_; 756 ssl_info->pkp_bypassed = pkp_bypassed_;
804 ssl_info->public_key_hashes = server_cert_verify_result_.public_key_hashes; 757 ssl_info->public_key_hashes = server_cert_verify_result_.public_key_hashes;
805 ssl_info->client_cert_sent = 758 ssl_info->client_cert_sent =
(...skipping 29 matching lines...) Expand all
835 out->clear(); 788 out->clear();
836 } 789 }
837 790
838 int64_t SSLClientSocketImpl::GetTotalReceivedBytes() const { 791 int64_t SSLClientSocketImpl::GetTotalReceivedBytes() const {
839 return transport_->socket()->GetTotalReceivedBytes(); 792 return transport_->socket()->GetTotalReceivedBytes();
840 } 793 }
841 794
842 void SSLClientSocketImpl::DumpMemoryStats(SocketMemoryStats* stats) const { 795 void SSLClientSocketImpl::DumpMemoryStats(SocketMemoryStats* stats) const {
843 if (transport_adapter_) 796 if (transport_adapter_)
844 stats->buffer_size = transport_adapter_->GetAllocationSize(); 797 stats->buffer_size = transport_adapter_->GetAllocationSize();
845 if (server_cert_chain_) { 798 STACK_OF(X509)* server_cert_chain = SSL_get_peer_cert_chain(ssl_.get());
846 for (size_t i = 0; i < server_cert_chain_->size(); ++i) { 799 if (server_cert_chain) {
847 X509* cert = server_cert_chain_->Get(i); 800 for (size_t i = 0; i < sk_X509_num(server_cert_chain); ++i) {
801 X509* cert = sk_X509_value(server_cert_chain, i);
848 // Estimate the size of the certificate before deduplication. 802 // Estimate the size of the certificate before deduplication.
849 // The multiplier (4) is added to account for the difference between the 803 // The multiplier (4) is added to account for the difference between the
850 // serialized cert size and the actual cert allocation. 804 // serialized cert size and the actual cert allocation.
851 // TODO(xunjieli): Update this after crbug.com/671420 is done. 805 // TODO(xunjieli): Update this after crbug.com/671420 is done.
852 stats->cert_size += 4 * i2d_X509(cert, nullptr); 806 stats->cert_size += 4 * i2d_X509(cert, nullptr);
853 } 807 }
854 stats->cert_count = server_cert_chain_->size(); 808 stats->cert_count = sk_X509_num(server_cert_chain);
855 } 809 }
856 stats->total_size = stats->buffer_size + stats->cert_size; 810 stats->total_size = stats->buffer_size + stats->cert_size;
857 } 811 }
858 812
859 // static 813 // static
860 void SSLClientSocketImpl::DumpSSLClientSessionMemoryStats( 814 void SSLClientSocketImpl::DumpSSLClientSessionMemoryStats(
861 base::trace_event::ProcessMemoryDump* pmd) { 815 base::trace_event::ProcessMemoryDump* pmd) {
862 SSLContext::GetInstance()->session_cache()->DumpMemoryStats(pmd); 816 SSLContext::GetInstance()->session_cache()->DumpMemoryStats(pmd);
863 } 817 }
864 818
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
1194 if (!IsRenegotiationAllowed()) 1148 if (!IsRenegotiationAllowed())
1195 SSL_set_renegotiate_mode(ssl_.get(), ssl_renegotiate_never); 1149 SSL_set_renegotiate_mode(ssl_.get(), ssl_renegotiate_never);
1196 1150
1197 uint16_t signature_algorithm = SSL_get_peer_signature_algorithm(ssl_.get()); 1151 uint16_t signature_algorithm = SSL_get_peer_signature_algorithm(ssl_.get());
1198 if (signature_algorithm != 0) { 1152 if (signature_algorithm != 0) {
1199 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.SSLSignatureAlgorithm", 1153 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.SSLSignatureAlgorithm",
1200 signature_algorithm); 1154 signature_algorithm);
1201 } 1155 }
1202 1156
1203 // Verify the certificate. 1157 // Verify the certificate.
1204 UpdateServerCert();
1205 next_handshake_state_ = STATE_VERIFY_CERT; 1158 next_handshake_state_ = STATE_VERIFY_CERT;
1206 return OK; 1159 return OK;
1207 } 1160 }
1208 1161
1209 int SSLClientSocketImpl::DoChannelIDLookup() { 1162 int SSLClientSocketImpl::DoChannelIDLookup() {
1210 NetLogParametersCallback callback = base::Bind( 1163 NetLogParametersCallback callback = base::Bind(
1211 &NetLogChannelIDLookupCallback, base::Unretained(channel_id_service_)); 1164 &NetLogChannelIDLookupCallback, base::Unretained(channel_id_service_));
1212 net_log_.BeginEvent(NetLogEventType::SSL_GET_CHANNEL_ID, callback); 1165 net_log_.BeginEvent(NetLogEventType::SSL_GET_CHANNEL_ID, callback);
1213 next_handshake_state_ = STATE_CHANNEL_ID_LOOKUP_COMPLETE; 1166 next_handshake_state_ = STATE_CHANNEL_ID_LOOKUP_COMPLETE;
1214 return channel_id_service_->GetOrCreateChannelID( 1167 return channel_id_service_->GetOrCreateChannelID(
(...skipping 19 matching lines...) Expand all
1234 return ERR_FAILED; 1187 return ERR_FAILED;
1235 } 1188 }
1236 1189
1237 // Return to the handshake. 1190 // Return to the handshake.
1238 channel_id_sent_ = true; 1191 channel_id_sent_ = true;
1239 next_handshake_state_ = STATE_HANDSHAKE; 1192 next_handshake_state_ = STATE_HANDSHAKE;
1240 return OK; 1193 return OK;
1241 } 1194 }
1242 1195
1243 int SSLClientSocketImpl::DoVerifyCert(int result) { 1196 int SSLClientSocketImpl::DoVerifyCert(int result) {
1244 DCHECK(!server_cert_chain_->empty());
1245 DCHECK(start_cert_verification_time_.is_null()); 1197 DCHECK(start_cert_verification_time_.is_null());
1246 1198
1247 next_handshake_state_ = STATE_VERIFY_CERT_COMPLETE; 1199 server_cert_ = OSChainFromOpenSSL(SSL_get_peer_cert_chain(ssl_.get()));
1248 1200
1249 // OpenSSL decoded the certificate, but the platform certificate 1201 // OpenSSL decoded the certificate, but the platform certificate
1250 // implementation could not. This is treated as a fatal SSL-level protocol 1202 // implementation could not. This is treated as a fatal SSL-level protocol
1251 // error rather than a certificate error. See https://crbug.com/91341. 1203 // error rather than a certificate error. See https://crbug.com/91341.
1252 if (!server_cert_) 1204 if (!server_cert_)
1253 return ERR_SSL_SERVER_CERT_BAD_FORMAT; 1205 return ERR_SSL_SERVER_CERT_BAD_FORMAT;
1254 1206
1207 net_log_.AddEvent(NetLogEventType::SSL_CERTIFICATES_RECEIVED,
1208 base::Bind(&NetLogX509CertificateCallback,
1209 base::Unretained(server_cert_.get())));
1210
1211 next_handshake_state_ = STATE_VERIFY_CERT_COMPLETE;
1212
1255 // If the certificate is bad and has been previously accepted, use 1213 // If the certificate is bad and has been previously accepted, use
1256 // the previous status and bypass the error. 1214 // the previous status and bypass the error.
1257 CertStatus cert_status; 1215 CertStatus cert_status;
1258 if (ssl_config_.IsAllowedBadCert(server_cert_.get(), &cert_status)) { 1216 if (ssl_config_.IsAllowedBadCert(server_cert_.get(), &cert_status)) {
1259 server_cert_verify_result_.Reset(); 1217 server_cert_verify_result_.Reset();
1260 server_cert_verify_result_.cert_status = cert_status; 1218 server_cert_verify_result_.cert_status = cert_status;
1261 server_cert_verify_result_.verified_cert = server_cert_; 1219 server_cert_verify_result_.verified_cert = server_cert_;
1262 return OK; 1220 return OK;
1263 } 1221 }
1264 1222
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1349 } 1307 }
1350 1308
1351 void SSLClientSocketImpl::DoConnectCallback(int rv) { 1309 void SSLClientSocketImpl::DoConnectCallback(int rv) {
1352 if (!user_connect_callback_.is_null()) { 1310 if (!user_connect_callback_.is_null()) {
1353 CompletionCallback c = user_connect_callback_; 1311 CompletionCallback c = user_connect_callback_;
1354 user_connect_callback_.Reset(); 1312 user_connect_callback_.Reset();
1355 c.Run(rv > OK ? OK : rv); 1313 c.Run(rv > OK ? OK : rv);
1356 } 1314 }
1357 } 1315 }
1358 1316
1359 void SSLClientSocketImpl::UpdateServerCert() {
1360 server_cert_chain_->Reset(SSL_get_peer_cert_chain(ssl_.get()));
1361 server_cert_ = server_cert_chain_->AsOSChain();
1362 if (server_cert_.get()) {
1363 net_log_.AddEvent(NetLogEventType::SSL_CERTIFICATES_RECEIVED,
1364 base::Bind(&NetLogX509CertificateCallback,
1365 base::Unretained(server_cert_.get())));
1366 }
1367 }
1368
1369 void SSLClientSocketImpl::OnHandshakeIOComplete(int result) { 1317 void SSLClientSocketImpl::OnHandshakeIOComplete(int result) {
1370 int rv = DoHandshakeLoop(result); 1318 int rv = DoHandshakeLoop(result);
1371 if (rv != ERR_IO_PENDING) { 1319 if (rv != ERR_IO_PENDING) {
1372 LogConnectEndEvent(rv); 1320 LogConnectEndEvent(rv);
1373 DoConnectCallback(rv); 1321 DoConnectCallback(rv);
1374 } 1322 }
1375 } 1323 }
1376 1324
1377 int SSLClientSocketImpl::DoHandshakeLoop(int last_io_result) { 1325 int SSLClientSocketImpl::DoHandshakeLoop(int last_io_result) {
1378 TRACE_EVENT0(kNetTracingCategory, "SSLClientSocketImpl::DoHandshakeLoop"); 1326 TRACE_EVENT0(kNetTracingCategory, "SSLClientSocketImpl::DoHandshakeLoop");
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
1726 return 1; 1674 return 1;
1727 } 1675 }
1728 #endif // defined(OS_IOS) 1676 #endif // defined(OS_IOS)
1729 1677
1730 // Send no client certificate. 1678 // Send no client certificate.
1731 net_log_.AddEvent(NetLogEventType::SSL_CLIENT_CERT_PROVIDED, 1679 net_log_.AddEvent(NetLogEventType::SSL_CLIENT_CERT_PROVIDED,
1732 NetLog::IntCallback("cert_count", 0)); 1680 NetLog::IntCallback("cert_count", 0));
1733 return 1; 1681 return 1;
1734 } 1682 }
1735 1683
1736 int SSLClientSocketImpl::CertVerifyCallback(X509_STORE_CTX* store_ctx) { 1684 int SSLClientSocketImpl::CertVerifyCallback(X509_STORE_CTX* store_ctx) {
svaldez 2017/03/07 15:05:04 Can we just remove the CertVerifyCallback entirely
davidben 2017/03/07 17:25:25 This is what stops us from running OpenSSL's verif
1737 if (!completed_connect_) { 1685 // The server certificate is verified later in DoVerifyCert.
1738 // If the first handshake hasn't completed then we accept any certificates
1739 // because we verify after the handshake.
1740 return 1;
1741 }
1742
1743 // Disallow the server certificate to change in a renegotiation.
1744 if (server_cert_chain_->empty()) {
1745 LOG(ERROR) << "Received invalid certificate chain between handshakes";
1746 return 0;
1747 }
1748 base::StringPiece old_der, new_der;
1749 if (store_ctx->cert == NULL ||
1750 !x509_util::GetDER(server_cert_chain_->Get(0), &old_der) ||
1751 !x509_util::GetDER(store_ctx->cert, &new_der)) {
1752 LOG(ERROR) << "Failed to encode certificates";
1753 return 0;
1754 }
1755 if (old_der != new_der) {
1756 LOG(ERROR) << "Server certificate changed between handshakes";
1757 return 0;
1758 }
1759
1760 return 1; 1686 return 1;
1761 } 1687 }
1762 1688
1763 void SSLClientSocketImpl::MaybeCacheSession() { 1689 void SSLClientSocketImpl::MaybeCacheSession() {
1764 // Only cache the session once both a new session has been established and the 1690 // Only cache the session once both a new session has been established and the
1765 // certificate has been verified. Due to False Start, these events may happen 1691 // certificate has been verified. Due to False Start, these events may happen
1766 // in either order. 1692 // in either order.
1767 if (!pending_session_ || !certificate_verified_) 1693 if (!pending_session_ || !certificate_verified_)
1768 return; 1694 return;
1769 1695
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
2051 if (ERR_GET_REASON(info->error_code) == SSL_R_TLSV1_ALERT_ACCESS_DENIED && 1977 if (ERR_GET_REASON(info->error_code) == SSL_R_TLSV1_ALERT_ACCESS_DENIED &&
2052 !certificate_requested_) { 1978 !certificate_requested_) {
2053 net_error = ERR_SSL_PROTOCOL_ERROR; 1979 net_error = ERR_SSL_PROTOCOL_ERROR;
2054 } 1980 }
2055 } 1981 }
2056 1982
2057 return net_error; 1983 return net_error;
2058 } 1984 }
2059 1985
2060 } // namespace net 1986 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698