Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 937 // 6066, Section 3). | 937 // 6066, Section 3). |
| 938 // | 938 // |
| 939 // TODO(rsleevi): Should this code allow hostnames that violate the LDH rule? | 939 // TODO(rsleevi): Should this code allow hostnames that violate the LDH rule? |
| 940 // See https://crbug.com/496472 and https://crbug.com/496468 for discussion. | 940 // See https://crbug.com/496472 and https://crbug.com/496468 for discussion. |
| 941 IPAddress unused; | 941 IPAddress unused; |
| 942 if (!unused.AssignFromIPLiteral(host_and_port_.host()) && | 942 if (!unused.AssignFromIPLiteral(host_and_port_.host()) && |
| 943 !SSL_set_tlsext_host_name(ssl_.get(), host_and_port_.host().c_str())) { | 943 !SSL_set_tlsext_host_name(ssl_.get(), host_and_port_.host().c_str())) { |
| 944 return ERR_UNEXPECTED; | 944 return ERR_UNEXPECTED; |
| 945 } | 945 } |
| 946 | 946 |
| 947 bssl::UniquePtr<SSL_SESSION> session = | 947 bssl::UniquePtr<SSL_SESSION> session = context->session_cache()->Lookup( |
| 948 context->session_cache()->Lookup(GetSessionCacheKey()); | 948 GetSessionCacheKey(), &ssl_session_cache_lookup_count_); |
| 949 if (session) | 949 if (session) |
| 950 SSL_set_session(ssl_.get(), session.get()); | 950 SSL_set_session(ssl_.get(), session.get()); |
| 951 | 951 |
| 952 transport_adapter_.reset(new SocketBIOAdapter( | 952 transport_adapter_.reset(new SocketBIOAdapter( |
| 953 transport_->socket(), GetBufferSize("SSLBufferSizeRecv"), | 953 transport_->socket(), GetBufferSize("SSLBufferSizeRecv"), |
| 954 GetBufferSize("SSLBufferSizeSend"), this)); | 954 GetBufferSize("SSLBufferSizeSend"), this)); |
| 955 BIO* transport_bio = transport_adapter_->bio(); | 955 BIO* transport_bio = transport_adapter_->bio(); |
| 956 | 956 |
| 957 BIO_up_ref(transport_bio); // SSL_set0_rbio takes ownership. | 957 BIO_up_ref(transport_bio); // SSL_set0_rbio takes ownership. |
| 958 SSL_set0_rbio(ssl_.get(), transport_bio); | 958 SSL_set0_rbio(ssl_.get(), transport_bio); |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1139 } | 1139 } |
| 1140 | 1140 |
| 1141 next_handshake_state_ = STATE_HANDSHAKE_COMPLETE; | 1141 next_handshake_state_ = STATE_HANDSHAKE_COMPLETE; |
| 1142 return net_error; | 1142 return net_error; |
| 1143 } | 1143 } |
| 1144 | 1144 |
| 1145 int SSLClientSocketImpl::DoHandshakeComplete(int result) { | 1145 int SSLClientSocketImpl::DoHandshakeComplete(int result) { |
| 1146 if (result < 0) | 1146 if (result < 0) |
| 1147 return result; | 1147 return result; |
| 1148 | 1148 |
| 1149 if (ssl_session_cache_lookup_count_) { | |
| 1150 SSLContext::GetInstance()->session_cache()->ResetLookupCount( | |
| 1151 GetSessionCacheKey(), SSL_get_session(ssl_.get())); | |
|
davidben
2017/01/19 20:29:34
Doesn't this want to be reset regardless of whethe
nharper
2017/01/19 21:50:35
Yes, that sounds right. We're modelling the server
| |
| 1152 if (negotiated_protocol_ == kProtoHTTP2 && SSL_session_reused(ssl_.get())) { | |
| 1153 UMA_HISTOGRAM_EXACT_LINEAR("Net.SSLSessionConcurrentLookupCount", | |
| 1154 ssl_session_cache_lookup_count_, 20); | |
|
davidben
2017/01/19 20:29:34
This should probably have a comment for what's goi
nharper
2017/01/19 21:50:35
Done.
| |
| 1155 } | |
| 1156 } | |
| 1157 | |
| 1149 // DHE is offered on the deprecated cipher fallback and then rejected | 1158 // DHE is offered on the deprecated cipher fallback and then rejected |
| 1150 // afterwards. This is to aid in diagnosing connection failures because a | 1159 // afterwards. This is to aid in diagnosing connection failures because a |
| 1151 // server requires DHE ciphers. | 1160 // server requires DHE ciphers. |
| 1152 // | 1161 // |
| 1153 // TODO(davidben): A few releases after DHE's removal, remove this logic. | 1162 // TODO(davidben): A few releases after DHE's removal, remove this logic. |
| 1154 if (!ssl_config_.dhe_enabled && | 1163 if (!ssl_config_.dhe_enabled && |
| 1155 SSL_CIPHER_is_DHE(SSL_get_current_cipher(ssl_.get()))) { | 1164 SSL_CIPHER_is_DHE(SSL_get_current_cipher(ssl_.get()))) { |
| 1156 return ERR_SSL_OBSOLETE_CIPHER; | 1165 return ERR_SSL_OBSOLETE_CIPHER; |
| 1157 } | 1166 } |
| 1158 | 1167 |
| (...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2065 if (ERR_GET_REASON(info->error_code) == SSL_R_TLSV1_ALERT_ACCESS_DENIED && | 2074 if (ERR_GET_REASON(info->error_code) == SSL_R_TLSV1_ALERT_ACCESS_DENIED && |
| 2066 !certificate_requested_) { | 2075 !certificate_requested_) { |
| 2067 net_error = ERR_SSL_PROTOCOL_ERROR; | 2076 net_error = ERR_SSL_PROTOCOL_ERROR; |
| 2068 } | 2077 } |
| 2069 } | 2078 } |
| 2070 | 2079 |
| 2071 return net_error; | 2080 return net_error; |
| 2072 } | 2081 } |
| 2073 | 2082 |
| 2074 } // namespace net | 2083 } // namespace net |
| OLD | NEW |