| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 #include "net/socket/ssl_client_socket_nss.h" | 48 #include "net/socket/ssl_client_socket_nss.h" |
| 49 | 49 |
| 50 #if defined(USE_SYSTEM_SSL) | 50 #if defined(USE_SYSTEM_SSL) |
| 51 #include <dlfcn.h> | 51 #include <dlfcn.h> |
| 52 #endif | 52 #endif |
| 53 #include <certdb.h> | 53 #include <certdb.h> |
| 54 #include <hasht.h> | 54 #include <hasht.h> |
| 55 #include <keyhi.h> | 55 #include <keyhi.h> |
| 56 #include <nspr.h> | 56 #include <nspr.h> |
| 57 #include <nss.h> | 57 #include <nss.h> |
| 58 #include <pk11pub.h> |
| 58 #include <secerr.h> | 59 #include <secerr.h> |
| 59 #include <sechash.h> | 60 #include <sechash.h> |
| 60 #include <ssl.h> | 61 #include <ssl.h> |
| 61 #include <sslerr.h> | 62 #include <sslerr.h> |
| 62 #include <pk11pub.h> | |
| 63 | 63 |
| 64 #include "base/compiler_specific.h" | 64 #include "base/compiler_specific.h" |
| 65 #include "base/histogram.h" | 65 #include "base/histogram.h" |
| 66 #include "base/logging.h" | 66 #include "base/logging.h" |
| 67 #include "base/nss_util.h" | 67 #include "base/nss_util.h" |
| 68 #include "base/singleton.h" | 68 #include "base/singleton.h" |
| 69 #include "base/string_number_conversions.h" | 69 #include "base/string_number_conversions.h" |
| 70 #include "base/string_util.h" | 70 #include "base/string_util.h" |
| 71 #include "base/stringprintf.h" |
| 71 #include "net/base/address_list.h" | 72 #include "net/base/address_list.h" |
| 72 #include "net/base/cert_status_flags.h" | 73 #include "net/base/cert_status_flags.h" |
| 73 #include "net/base/cert_verifier.h" | 74 #include "net/base/cert_verifier.h" |
| 75 #include "net/base/dns_util.h" |
| 74 #include "net/base/dnsrr_resolver.h" | 76 #include "net/base/dnsrr_resolver.h" |
| 75 #include "net/base/dnssec_chain_verifier.h" | 77 #include "net/base/dnssec_chain_verifier.h" |
| 76 #include "net/base/dns_util.h" | |
| 77 #include "net/base/io_buffer.h" | 78 #include "net/base/io_buffer.h" |
| 78 #include "net/base/net_errors.h" | 79 #include "net/base/net_errors.h" |
| 79 #include "net/base/net_log.h" | 80 #include "net/base/net_log.h" |
| 80 #include "net/base/ssl_cert_request_info.h" | 81 #include "net/base/ssl_cert_request_info.h" |
| 81 #include "net/base/ssl_connection_status_flags.h" | 82 #include "net/base/ssl_connection_status_flags.h" |
| 82 #include "net/base/ssl_info.h" | 83 #include "net/base/ssl_info.h" |
| 83 #include "net/base/sys_addrinfo.h" | 84 #include "net/base/sys_addrinfo.h" |
| 84 #include "net/ocsp/nss_ocsp.h" | 85 #include "net/ocsp/nss_ocsp.h" |
| 85 #include "net/socket/client_socket_handle.h" | 86 #include "net/socket/client_socket_handle.h" |
| 86 | 87 |
| (...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 return ERR_UNEXPECTED; | 569 return ERR_UNEXPECTED; |
| 569 | 570 |
| 570 // Tell SSL the hostname we're trying to connect to. | 571 // Tell SSL the hostname we're trying to connect to. |
| 571 SSL_SetURL(nss_fd_, hostname_.c_str()); | 572 SSL_SetURL(nss_fd_, hostname_.c_str()); |
| 572 | 573 |
| 573 // Set the peer ID for session reuse. This is necessary when we create an | 574 // Set the peer ID for session reuse. This is necessary when we create an |
| 574 // SSL tunnel through a proxy -- GetPeerName returns the proxy's address | 575 // SSL tunnel through a proxy -- GetPeerName returns the proxy's address |
| 575 // rather than the destination server's address in that case. | 576 // rather than the destination server's address in that case. |
| 576 // TODO(wtc): port in |peer_address| is not the server's port when a proxy is | 577 // TODO(wtc): port in |peer_address| is not the server's port when a proxy is |
| 577 // used. | 578 // used. |
| 578 std::string peer_id = StringPrintf("%s:%d", hostname_.c_str(), | 579 std::string peer_id = base::StringPrintf("%s:%d", hostname_.c_str(), |
| 579 peer_address.GetPort()); | 580 peer_address.GetPort()); |
| 580 rv = SSL_SetSockPeerID(nss_fd_, const_cast<char*>(peer_id.c_str())); | 581 rv = SSL_SetSockPeerID(nss_fd_, const_cast<char*>(peer_id.c_str())); |
| 581 if (rv != SECSuccess) | 582 if (rv != SECSuccess) |
| 582 LOG(INFO) << "SSL_SetSockPeerID failed: peer_id=" << peer_id; | 583 LOG(INFO) << "SSL_SetSockPeerID failed: peer_id=" << peer_id; |
| 583 | 584 |
| 584 // Tell SSL we're a client; needed if not letting NSPR do socket I/O | 585 // Tell SSL we're a client; needed if not letting NSPR do socket I/O |
| 585 SSL_ResetHandshake(nss_fd_, 0); | 586 SSL_ResetHandshake(nss_fd_, 0); |
| 586 | 587 |
| 587 return OK; | 588 return OK; |
| 588 } | 589 } |
| 589 | 590 |
| (...skipping 1299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1889 PRErrorCode prerr = PR_GetError(); | 1890 PRErrorCode prerr = PR_GetError(); |
| 1890 if (prerr == PR_WOULD_BLOCK_ERROR) { | 1891 if (prerr == PR_WOULD_BLOCK_ERROR) { |
| 1891 LeaveFunction(""); | 1892 LeaveFunction(""); |
| 1892 return ERR_IO_PENDING; | 1893 return ERR_IO_PENDING; |
| 1893 } | 1894 } |
| 1894 LeaveFunction(""); | 1895 LeaveFunction(""); |
| 1895 return MapNSPRError(prerr); | 1896 return MapNSPRError(prerr); |
| 1896 } | 1897 } |
| 1897 | 1898 |
| 1898 } // namespace net | 1899 } // namespace net |
| OLD | NEW |