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 // This file includes code SSLClientSocketNSS::DoVerifyCertComplete() derived | 5 // This file includes code SSLClientSocketNSS::DoVerifyCertComplete() derived |
| 6 // from AuthCertificateCallback() in | 6 // from AuthCertificateCallback() in |
| 7 // mozilla/security/manager/ssl/src/nsNSSCallbacks.cpp. | 7 // mozilla/security/manager/ssl/src/nsNSSCallbacks.cpp. |
| 8 | 8 |
| 9 /* ***** BEGIN LICENSE BLOCK ***** | 9 /* ***** BEGIN LICENSE BLOCK ***** |
| 10 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | 10 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 87 #include "net/base/dns_util.h" | 87 #include "net/base/dns_util.h" |
| 88 #include "net/base/dnssec_chain_verifier.h" | 88 #include "net/base/dnssec_chain_verifier.h" |
| 89 #include "net/base/transport_security_state.h" | 89 #include "net/base/transport_security_state.h" |
| 90 #include "net/base/io_buffer.h" | 90 #include "net/base/io_buffer.h" |
| 91 #include "net/base/net_errors.h" | 91 #include "net/base/net_errors.h" |
| 92 #include "net/base/net_log.h" | 92 #include "net/base/net_log.h" |
| 93 #include "net/base/single_request_cert_verifier.h" | 93 #include "net/base/single_request_cert_verifier.h" |
| 94 #include "net/base/ssl_cert_request_info.h" | 94 #include "net/base/ssl_cert_request_info.h" |
| 95 #include "net/base/ssl_connection_status_flags.h" | 95 #include "net/base/ssl_connection_status_flags.h" |
| 96 #include "net/base/ssl_info.h" | 96 #include "net/base/ssl_info.h" |
| 97 #include "net/base/sys_addrinfo.h" | |
| 98 #include "net/base/x509_certificate_net_log_param.h" | 97 #include "net/base/x509_certificate_net_log_param.h" |
| 99 #include "net/ocsp/nss_ocsp.h" | 98 #include "net/ocsp/nss_ocsp.h" |
| 100 #include "net/socket/client_socket_handle.h" | 99 #include "net/socket/client_socket_handle.h" |
| 101 #include "net/socket/nss_ssl_util.h" | 100 #include "net/socket/nss_ssl_util.h" |
| 102 #include "net/socket/ssl_error_params.h" | 101 #include "net/socket/ssl_error_params.h" |
| 103 #include "net/socket/ssl_host_info.h" | 102 #include "net/socket/ssl_host_info.h" |
| 104 | 103 |
| 105 #if defined(OS_WIN) | 104 #if defined(OS_WIN) |
| 106 #include <windows.h> | 105 #include <windows.h> |
| 107 #include <wincrypt.h> | 106 #include <wincrypt.h> |
| (...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1016 return OK; | 1015 return OK; |
| 1017 } | 1016 } |
| 1018 | 1017 |
| 1019 int SSLClientSocketNSS::InitializeSSLPeerName() { | 1018 int SSLClientSocketNSS::InitializeSSLPeerName() { |
| 1020 // Tell NSS who we're connected to | 1019 // Tell NSS who we're connected to |
| 1021 AddressList peer_address; | 1020 AddressList peer_address; |
| 1022 int err = transport_->socket()->GetPeerAddress(&peer_address); | 1021 int err = transport_->socket()->GetPeerAddress(&peer_address); |
| 1023 if (err != OK) | 1022 if (err != OK) |
| 1024 return err; | 1023 return err; |
| 1025 | 1024 |
| 1026 const struct addrinfo* ai = peer_address.head(); | 1025 SockaddrStorage storage; |
| 1026 if (!peer_address[0].ToSockAddr(storage.addr, &storage.addr_len)) | |
|
eroman
2012/05/04 01:08:41
nit: [0] vs .front().
| |
| 1027 return ERR_UNEXPECTED; | |
| 1027 | 1028 |
| 1028 PRNetAddr peername; | 1029 PRNetAddr peername; |
| 1029 memset(&peername, 0, sizeof(peername)); | 1030 memset(&peername, 0, sizeof(peername)); |
| 1030 DCHECK_LE(ai->ai_addrlen, sizeof(peername)); | 1031 DCHECK_LE(static_cast<size_t>(storage.addr_len), sizeof(peername)); |
| 1031 size_t len = std::min(static_cast<size_t>(ai->ai_addrlen), | 1032 size_t len = std::min(static_cast<size_t>(storage.addr_len), |
| 1032 sizeof(peername)); | 1033 sizeof(peername)); |
| 1033 memcpy(&peername, ai->ai_addr, len); | 1034 memcpy(&peername, storage.addr, len); |
| 1034 | 1035 |
| 1035 // Adjust the address family field for BSD, whose sockaddr | 1036 // Adjust the address family field for BSD, whose sockaddr |
| 1036 // structure has a one-byte length and one-byte address family | 1037 // structure has a one-byte length and one-byte address family |
| 1037 // field at the beginning. PRNetAddr has a two-byte address | 1038 // field at the beginning. PRNetAddr has a two-byte address |
| 1038 // family field at the beginning. | 1039 // family field at the beginning. |
| 1039 peername.raw.family = ai->ai_addr->sa_family; | 1040 peername.raw.family = storage.addr->sa_family; |
| 1040 | 1041 |
| 1041 memio_SetPeerName(nss_fd_, &peername); | 1042 memio_SetPeerName(nss_fd_, &peername); |
| 1042 | 1043 |
| 1043 // Set the peer ID for session reuse. This is necessary when we create an | 1044 // Set the peer ID for session reuse. This is necessary when we create an |
| 1044 // SSL tunnel through a proxy -- GetPeerName returns the proxy's address | 1045 // SSL tunnel through a proxy -- GetPeerName returns the proxy's address |
| 1045 // rather than the destination server's address in that case. | 1046 // rather than the destination server's address in that case. |
| 1046 std::string peer_id = host_and_port_.ToString(); | 1047 std::string peer_id = host_and_port_.ToString(); |
| 1047 // If the ssl_session_cache_shard_ is non-empty, we append it to the peer id. | 1048 // If the ssl_session_cache_shard_ is non-empty, we append it to the peer id. |
| 1048 // This will cause session cache misses between sockets with different values | 1049 // This will cause session cache misses between sockets with different values |
| 1049 // of ssl_session_cache_shard_ and this is used to partition the session cache | 1050 // of ssl_session_cache_shard_ and this is used to partition the session cache |
| (...skipping 1606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2656 EnsureThreadIdAssigned(); | 2657 EnsureThreadIdAssigned(); |
| 2657 base::AutoLock auto_lock(lock_); | 2658 base::AutoLock auto_lock(lock_); |
| 2658 return valid_thread_id_ == base::PlatformThread::CurrentId(); | 2659 return valid_thread_id_ == base::PlatformThread::CurrentId(); |
| 2659 } | 2660 } |
| 2660 | 2661 |
| 2661 ServerBoundCertService* SSLClientSocketNSS::GetServerBoundCertService() const { | 2662 ServerBoundCertService* SSLClientSocketNSS::GetServerBoundCertService() const { |
| 2662 return server_bound_cert_service_; | 2663 return server_bound_cert_service_; |
| 2663 } | 2664 } |
| 2664 | 2665 |
| 2665 } // namespace net | 2666 } // namespace net |
| OLD | NEW |