 Chromium Code Reviews
 Chromium Code Reviews Issue 4339001:
  Correctly handle SSL Client Authentication requests when connecting...  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src/
    
  
    Issue 4339001:
  Correctly handle SSL Client Authentication requests when connecting...  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src/| 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 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 411 | 411 | 
| 412 private: | 412 private: | 
| 413 unsigned num_certs_; | 413 unsigned num_certs_; | 
| 414 CERTCertificate** certs_; | 414 CERTCertificate** certs_; | 
| 415 }; | 415 }; | 
| 416 | 416 | 
| 417 } // namespace | 417 } // namespace | 
| 418 | 418 | 
| 419 SSLClientSocketNSS::SSLClientSocketNSS(ClientSocketHandle* transport_socket, | 419 SSLClientSocketNSS::SSLClientSocketNSS(ClientSocketHandle* transport_socket, | 
| 420 const std::string& hostname, | 420 const std::string& hostname, | 
| 421 uint16 port, | |
| 421 const SSLConfig& ssl_config, | 422 const SSLConfig& ssl_config, | 
| 422 SSLHostInfo* ssl_host_info, | 423 SSLHostInfo* ssl_host_info, | 
| 423 DnsRRResolver* dnsrr_resolver) | 424 DnsRRResolver* dnsrr_resolver) | 
| 424 : ALLOW_THIS_IN_INITIALIZER_LIST(buffer_send_callback_( | 425 : ALLOW_THIS_IN_INITIALIZER_LIST(buffer_send_callback_( | 
| 425 this, &SSLClientSocketNSS::BufferSendComplete)), | 426 this, &SSLClientSocketNSS::BufferSendComplete)), | 
| 426 ALLOW_THIS_IN_INITIALIZER_LIST(buffer_recv_callback_( | 427 ALLOW_THIS_IN_INITIALIZER_LIST(buffer_recv_callback_( | 
| 427 this, &SSLClientSocketNSS::BufferRecvComplete)), | 428 this, &SSLClientSocketNSS::BufferRecvComplete)), | 
| 428 transport_send_busy_(false), | 429 transport_send_busy_(false), | 
| 429 transport_recv_busy_(false), | 430 transport_recv_busy_(false), | 
| 430 corked_(false), | 431 corked_(false), | 
| 431 ALLOW_THIS_IN_INITIALIZER_LIST(handshake_io_callback_( | 432 ALLOW_THIS_IN_INITIALIZER_LIST(handshake_io_callback_( | 
| 432 this, &SSLClientSocketNSS::OnHandshakeIOComplete)), | 433 this, &SSLClientSocketNSS::OnHandshakeIOComplete)), | 
| 433 transport_(transport_socket), | 434 transport_(transport_socket), | 
| 434 hostname_(hostname), | 435 hostname_(hostname), | 
| 436 port_(port), | |
| 435 ssl_config_(ssl_config), | 437 ssl_config_(ssl_config), | 
| 436 user_connect_callback_(NULL), | 438 user_connect_callback_(NULL), | 
| 437 user_read_callback_(NULL), | 439 user_read_callback_(NULL), | 
| 438 user_write_callback_(NULL), | 440 user_write_callback_(NULL), | 
| 439 user_read_buf_len_(0), | 441 user_read_buf_len_(0), | 
| 440 user_write_buf_len_(0), | 442 user_write_buf_len_(0), | 
| 441 server_cert_nss_(NULL), | 443 server_cert_nss_(NULL), | 
| 442 server_cert_verify_result_(NULL), | 444 server_cert_verify_result_(NULL), | 
| 443 ssl_connection_status_(0), | 445 ssl_connection_status_(0), | 
| 444 client_auth_cert_needed_(false), | 446 client_auth_cert_needed_(false), | 
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 864 // structure has a one-byte length and one-byte address family | 866 // structure has a one-byte length and one-byte address family | 
| 865 // field at the beginning. PRNetAddr has a two-byte address | 867 // field at the beginning. PRNetAddr has a two-byte address | 
| 866 // family field at the beginning. | 868 // family field at the beginning. | 
| 867 peername.raw.family = ai->ai_addr->sa_family; | 869 peername.raw.family = ai->ai_addr->sa_family; | 
| 868 | 870 | 
| 869 memio_SetPeerName(nss_fd_, &peername); | 871 memio_SetPeerName(nss_fd_, &peername); | 
| 870 | 872 | 
| 871 // Set the peer ID for session reuse. This is necessary when we create an | 873 // Set the peer ID for session reuse. This is necessary when we create an | 
| 872 // SSL tunnel through a proxy -- GetPeerName returns the proxy's address | 874 // SSL tunnel through a proxy -- GetPeerName returns the proxy's address | 
| 873 // rather than the destination server's address in that case. | 875 // rather than the destination server's address in that case. | 
| 874 // TODO(wtc): port in |peer_address| is not the server's port when a proxy is | 876 // TODO(wtc): port in |peer_address| is not the server's port when a proxy is | 
| 
wtc
2010/11/11 01:11:35
Please fix this TODO by replacing the base::String
 
Ryan Hamilton
2010/11/11 18:57:00
Done.
 | |
| 875 // used. | 877 // used. | 
| 876 std::string peer_id = base::StringPrintf("%s:%d", hostname_.c_str(), | 878 std::string peer_id = base::StringPrintf("%s:%d", hostname_.c_str(), | 
| 877 peer_address.GetPort()); | 879 peer_address.GetPort()); | 
| 878 SECStatus rv = SSL_SetSockPeerID(nss_fd_, const_cast<char*>(peer_id.c_str())); | 880 SECStatus rv = SSL_SetSockPeerID(nss_fd_, const_cast<char*>(peer_id.c_str())); | 
| 879 if (rv != SECSuccess) | 881 if (rv != SECSuccess) | 
| 880 LogFailedNSSFunction(net_log_, "SSL_SetSockPeerID", peer_id.c_str()); | 882 LogFailedNSSFunction(net_log_, "SSL_SetSockPeerID", peer_id.c_str()); | 
| 881 | 883 | 
| 882 peername_initialized_ = true; | 884 peername_initialized_ = true; | 
| 883 return OK; | 885 return OK; | 
| 884 } | 886 } | 
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1193 ssl_info->security_bits = -1; | 1195 ssl_info->security_bits = -1; | 
| 1194 LOG(DFATAL) << "SSL_GetCipherSuiteInfo returned " << PR_GetError() | 1196 LOG(DFATAL) << "SSL_GetCipherSuiteInfo returned " << PR_GetError() | 
| 1195 << " for cipherSuite " << cipher_suite; | 1197 << " for cipherSuite " << cipher_suite; | 
| 1196 } | 1198 } | 
| 1197 LeaveFunction(""); | 1199 LeaveFunction(""); | 
| 1198 } | 1200 } | 
| 1199 | 1201 | 
| 1200 void SSLClientSocketNSS::GetSSLCertRequestInfo( | 1202 void SSLClientSocketNSS::GetSSLCertRequestInfo( | 
| 1201 SSLCertRequestInfo* cert_request_info) { | 1203 SSLCertRequestInfo* cert_request_info) { | 
| 1202 EnterFunction(""); | 1204 EnterFunction(""); | 
| 1203 cert_request_info->host_and_port = hostname_; // TODO(wtc): no port! | 1205 cert_request_info->host_and_port = HostPortPair(hostname_, port_).ToString(); | 
| 1204 cert_request_info->client_certs = client_certs_; | 1206 cert_request_info->client_certs = client_certs_; | 
| 1205 LeaveFunction(cert_request_info->client_certs.size()); | 1207 LeaveFunction(cert_request_info->client_certs.size()); | 
| 1206 } | 1208 } | 
| 1207 | 1209 | 
| 1208 SSLClientSocket::NextProtoStatus | 1210 SSLClientSocket::NextProtoStatus | 
| 1209 SSLClientSocketNSS::GetNextProto(std::string* proto) { | 1211 SSLClientSocketNSS::GetNextProto(std::string* proto) { | 
| 1210 #if defined(SSL_NEXT_PROTO_NEGOTIATED) | 1212 #if defined(SSL_NEXT_PROTO_NEGOTIATED) | 
| 1211 if (!handshake_callback_called_) { | 1213 if (!handshake_callback_called_) { | 
| 1212 DCHECK(pseudo_connected_); | 1214 DCHECK(pseudo_connected_); | 
| 1213 predicted_npn_proto_used_ = true; | 1215 predicted_npn_proto_used_ = true; | 
| (...skipping 1094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2308 if (verifier.rrtype() != kDNS_TXT) | 2310 if (verifier.rrtype() != kDNS_TXT) | 
| 2309 return DNSVR_CONTINUE; | 2311 return DNSVR_CONTINUE; | 
| 2310 | 2312 | 
| 2311 DNSValidationResult r = VerifyTXTRecords( | 2313 DNSValidationResult r = VerifyTXTRecords( | 
| 2312 true /* DNSSEC verified */, server_cert_nss, verifier.rrdatas()); | 2314 true /* DNSSEC verified */, server_cert_nss, verifier.rrdatas()); | 
| 2313 SECITEM_FreeItem(&dnssec_embedded_chain, PR_FALSE); | 2315 SECITEM_FreeItem(&dnssec_embedded_chain, PR_FALSE); | 
| 2314 return r; | 2316 return r; | 
| 2315 } | 2317 } | 
| 2316 | 2318 | 
| 2317 int SSLClientSocketNSS::DoVerifyDNSSEC(int result) { | 2319 int SSLClientSocketNSS::DoVerifyDNSSEC(int result) { | 
| 2318 #if !defined(USE_OPENSSL) | 2320 #if !defined(USE_OPENSSL) | 
| 
wtc
2010/11/11 01:11:35
I think we should remove this ifdef.  By definitio
 
Ryan Hamilton
2010/11/11 18:57:00
Done.
 | |
| 2319 if (ssl_config_.dns_cert_provenance_checking_enabled && dnsrr_resolver_) { | 2321 if (ssl_config_.dns_cert_provenance_checking_enabled && dnsrr_resolver_) { | 
| 2320 PeerCertificateChain certs(nss_fd_); | 2322 PeerCertificateChain certs(nss_fd_); | 
| 2321 DoAsyncDNSCertProvenanceVerification( | 2323 DoAsyncDNSCertProvenanceVerification( | 
| 2322 hostname_, dnsrr_resolver_, certs.AsStringPieceVector()); | 2324 hostname_, dnsrr_resolver_, certs.AsStringPieceVector()); | 
| 2323 } | 2325 } | 
| 2324 #endif | 2326 #endif | 
| 2325 | 2327 | 
| 2326 if (ssl_config_.dnssec_enabled) { | 2328 if (ssl_config_.dnssec_enabled) { | 
| 2327 DNSValidationResult r = CheckDNSSECChain(hostname_, server_cert_nss_); | 2329 DNSValidationResult r = CheckDNSSECChain(hostname_, server_cert_nss_); | 
| 2328 if (r == DNSVR_SUCCESS) { | 2330 if (r == DNSVR_SUCCESS) { | 
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2576 case SSL_CONNECTION_VERSION_TLS1_1: | 2578 case SSL_CONNECTION_VERSION_TLS1_1: | 
| 2577 UpdateConnectionTypeHistograms(CONNECTION_SSL_TLS1_1); | 2579 UpdateConnectionTypeHistograms(CONNECTION_SSL_TLS1_1); | 
| 2578 break; | 2580 break; | 
| 2579 case SSL_CONNECTION_VERSION_TLS1_2: | 2581 case SSL_CONNECTION_VERSION_TLS1_2: | 
| 2580 UpdateConnectionTypeHistograms(CONNECTION_SSL_TLS1_2); | 2582 UpdateConnectionTypeHistograms(CONNECTION_SSL_TLS1_2); | 
| 2581 break; | 2583 break; | 
| 2582 }; | 2584 }; | 
| 2583 } | 2585 } | 
| 2584 | 2586 | 
| 2585 } // namespace net | 2587 } // namespace net | 
| OLD | NEW |