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 // 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> |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 *hash = SSLPrivateKey::Hash::SHA384; | 111 *hash = SSLPrivateKey::Hash::SHA384; |
112 return true; | 112 return true; |
113 case NID_sha512: | 113 case NID_sha512: |
114 *hash = SSLPrivateKey::Hash::SHA512; | 114 *hash = SSLPrivateKey::Hash::SHA512; |
115 return true; | 115 return true; |
116 default: | 116 default: |
117 return false; | 117 return false; |
118 } | 118 } |
119 } | 119 } |
120 | 120 |
121 scoped_ptr<base::Value> NetLogPrivateKeyOperationCallback( | 121 std::unique_ptr<base::Value> NetLogPrivateKeyOperationCallback( |
122 SSLPrivateKey::Type type, | 122 SSLPrivateKey::Type type, |
123 SSLPrivateKey::Hash hash, | 123 SSLPrivateKey::Hash hash, |
124 NetLogCaptureMode mode) { | 124 NetLogCaptureMode mode) { |
125 std::string type_str; | 125 std::string type_str; |
126 switch (type) { | 126 switch (type) { |
127 case SSLPrivateKey::Type::RSA: | 127 case SSLPrivateKey::Type::RSA: |
128 type_str = "RSA"; | 128 type_str = "RSA"; |
129 break; | 129 break; |
130 case SSLPrivateKey::Type::ECDSA: | 130 case SSLPrivateKey::Type::ECDSA: |
131 type_str = "ECDSA"; | 131 type_str = "ECDSA"; |
(...skipping 12 matching lines...) Expand all Loading... |
144 hash_str = "SHA256"; | 144 hash_str = "SHA256"; |
145 break; | 145 break; |
146 case SSLPrivateKey::Hash::SHA384: | 146 case SSLPrivateKey::Hash::SHA384: |
147 hash_str = "SHA384"; | 147 hash_str = "SHA384"; |
148 break; | 148 break; |
149 case SSLPrivateKey::Hash::SHA512: | 149 case SSLPrivateKey::Hash::SHA512: |
150 hash_str = "SHA512"; | 150 hash_str = "SHA512"; |
151 break; | 151 break; |
152 } | 152 } |
153 | 153 |
154 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue); | 154 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue); |
155 value->SetString("type", type_str); | 155 value->SetString("type", type_str); |
156 value->SetString("hash", hash_str); | 156 value->SetString("hash", hash_str); |
157 return std::move(value); | 157 return std::move(value); |
158 } | 158 } |
159 | 159 |
160 scoped_ptr<base::Value> NetLogChannelIDLookupCallback( | 160 std::unique_ptr<base::Value> NetLogChannelIDLookupCallback( |
161 ChannelIDService* channel_id_service, | 161 ChannelIDService* channel_id_service, |
162 NetLogCaptureMode capture_mode) { | 162 NetLogCaptureMode capture_mode) { |
163 ChannelIDStore* store = channel_id_service->GetChannelIDStore(); | 163 ChannelIDStore* store = channel_id_service->GetChannelIDStore(); |
164 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 164 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
165 dict->SetBoolean("ephemeral", store->IsEphemeral()); | 165 dict->SetBoolean("ephemeral", store->IsEphemeral()); |
166 dict->SetString("service", base::HexEncode(&channel_id_service, | 166 dict->SetString("service", base::HexEncode(&channel_id_service, |
167 sizeof(channel_id_service))); | 167 sizeof(channel_id_service))); |
168 dict->SetString("store", base::HexEncode(&store, sizeof(store))); | 168 dict->SetString("store", base::HexEncode(&store, sizeof(store))); |
169 return std::move(dict); | 169 return std::move(dict); |
170 } | 170 } |
171 | 171 |
172 scoped_ptr<base::Value> NetLogChannelIDLookupCompleteCallback( | 172 std::unique_ptr<base::Value> NetLogChannelIDLookupCompleteCallback( |
173 crypto::ECPrivateKey* key, | 173 crypto::ECPrivateKey* key, |
174 int result, | 174 int result, |
175 NetLogCaptureMode capture_mode) { | 175 NetLogCaptureMode capture_mode) { |
176 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 176 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
177 dict->SetInteger("net_error", result); | 177 dict->SetInteger("net_error", result); |
178 std::string raw_key; | 178 std::string raw_key; |
179 if (result == OK && key && key->ExportRawPublicKey(&raw_key)) { | 179 if (result == OK && key && key->ExportRawPublicKey(&raw_key)) { |
180 std::string key_to_log = "redacted"; | 180 std::string key_to_log = "redacted"; |
181 if (capture_mode.include_cookies_and_credentials()) { | 181 if (capture_mode.include_cookies_and_credentials()) { |
182 key_to_log = base::HexEncode(raw_key.data(), raw_key.length()); | 182 key_to_log = base::HexEncode(raw_key.data(), raw_key.length()); |
183 } | 183 } |
184 dict->SetString("key", key_to_log); | 184 dict->SetString("key", key_to_log); |
185 } | 185 } |
186 return std::move(dict); | 186 return std::move(dict); |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 } | 353 } |
354 #endif | 354 #endif |
355 | 355 |
356 // This is the index used with SSL_get_ex_data to retrieve the owner | 356 // This is the index used with SSL_get_ex_data to retrieve the owner |
357 // SSLClientSocketOpenSSL object from an SSL instance. | 357 // SSLClientSocketOpenSSL object from an SSL instance. |
358 int ssl_socket_data_index_; | 358 int ssl_socket_data_index_; |
359 | 359 |
360 ScopedSSL_CTX ssl_ctx_; | 360 ScopedSSL_CTX ssl_ctx_; |
361 | 361 |
362 #if !defined(OS_NACL) | 362 #if !defined(OS_NACL) |
363 scoped_ptr<SSLKeyLogger> ssl_key_logger_; | 363 std::unique_ptr<SSLKeyLogger> ssl_key_logger_; |
364 #endif | 364 #endif |
365 | 365 |
366 // TODO(davidben): Use a separate cache per URLRequestContext. | 366 // TODO(davidben): Use a separate cache per URLRequestContext. |
367 // https://crbug.com/458365 | 367 // https://crbug.com/458365 |
368 // | 368 // |
369 // TODO(davidben): Sessions should be invalidated on fatal | 369 // TODO(davidben): Sessions should be invalidated on fatal |
370 // alerts. https://crbug.com/466352 | 370 // alerts. https://crbug.com/466352 |
371 SSLClientSessionCacheOpenSSL session_cache_; | 371 SSLClientSessionCacheOpenSSL session_cache_; |
372 }; | 372 }; |
373 | 373 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 } | 461 } |
462 | 462 |
463 // static | 463 // static |
464 void SSLClientSocket::ClearSessionCache() { | 464 void SSLClientSocket::ClearSessionCache() { |
465 SSLClientSocketOpenSSL::SSLContext* context = | 465 SSLClientSocketOpenSSL::SSLContext* context = |
466 SSLClientSocketOpenSSL::SSLContext::GetInstance(); | 466 SSLClientSocketOpenSSL::SSLContext::GetInstance(); |
467 context->session_cache()->Flush(); | 467 context->session_cache()->Flush(); |
468 } | 468 } |
469 | 469 |
470 SSLClientSocketOpenSSL::SSLClientSocketOpenSSL( | 470 SSLClientSocketOpenSSL::SSLClientSocketOpenSSL( |
471 scoped_ptr<ClientSocketHandle> transport_socket, | 471 std::unique_ptr<ClientSocketHandle> transport_socket, |
472 const HostPortPair& host_and_port, | 472 const HostPortPair& host_and_port, |
473 const SSLConfig& ssl_config, | 473 const SSLConfig& ssl_config, |
474 const SSLClientSocketContext& context) | 474 const SSLClientSocketContext& context) |
475 : transport_send_busy_(false), | 475 : transport_send_busy_(false), |
476 transport_recv_busy_(false), | 476 transport_recv_busy_(false), |
477 pending_read_error_(kNoPendingResult), | 477 pending_read_error_(kNoPendingResult), |
478 pending_read_ssl_error_(SSL_ERROR_NONE), | 478 pending_read_ssl_error_(SSL_ERROR_NONE), |
479 transport_read_error_(OK), | 479 transport_read_error_(OK), |
480 transport_write_error_(OK), | 480 transport_write_error_(OK), |
481 server_cert_chain_(new PeerCertificateChain(NULL)), | 481 server_cert_chain_(new PeerCertificateChain(NULL)), |
(...skipping 1823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2305 tb_was_negotiated_ = true; | 2305 tb_was_negotiated_ = true; |
2306 return 1; | 2306 return 1; |
2307 } | 2307 } |
2308 } | 2308 } |
2309 | 2309 |
2310 *out_alert_value = SSL_AD_ILLEGAL_PARAMETER; | 2310 *out_alert_value = SSL_AD_ILLEGAL_PARAMETER; |
2311 return 0; | 2311 return 0; |
2312 } | 2312 } |
2313 | 2313 |
2314 } // namespace net | 2314 } // namespace net |
OLD | NEW |