OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 2124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2135 bool SSLClientSocketNSS::OriginBoundCertNegotiated(PRFileDesc* socket) { | 2135 bool SSLClientSocketNSS::OriginBoundCertNegotiated(PRFileDesc* socket) { |
2136 PRBool xtn_negotiated = PR_FALSE; | 2136 PRBool xtn_negotiated = PR_FALSE; |
2137 SECStatus rv = SSL_HandshakeNegotiatedExtension( | 2137 SECStatus rv = SSL_HandshakeNegotiatedExtension( |
2138 socket, ssl_ob_cert_xtn, &xtn_negotiated); | 2138 socket, ssl_ob_cert_xtn, &xtn_negotiated); |
2139 DCHECK_EQ(SECSuccess, rv); | 2139 DCHECK_EQ(SECSuccess, rv); |
2140 | 2140 |
2141 return xtn_negotiated ? true : false; | 2141 return xtn_negotiated ? true : false; |
2142 } | 2142 } |
2143 | 2143 |
2144 SECStatus SSLClientSocketNSS::OriginBoundClientAuthHandler( | 2144 SECStatus SSLClientSocketNSS::OriginBoundClientAuthHandler( |
2145 const std::vector<uint8>& requested_cert_types, | 2145 const SECItem* cert_types, |
2146 CERTCertificate** result_certificate, | 2146 CERTCertificate** result_certificate, |
2147 SECKEYPrivateKey** result_private_key) { | 2147 SECKEYPrivateKey** result_private_key) { |
2148 ob_cert_xtn_negotiated_ = true; | 2148 ob_cert_xtn_negotiated_ = true; |
2149 | 2149 |
2150 // We have negotiated the origin-bound certificate extension. | 2150 // We have negotiated the origin-bound certificate extension. |
2151 std::string origin = "https://" + host_and_port_.ToString(); | 2151 std::string origin = "https://" + host_and_port_.ToString(); |
2152 std::vector<uint8> requested_cert_types(cert_types->data, | |
2153 cert_types->data + cert_types->len); | |
wtc
2011/12/06 02:47:58
Since we still need to convert to a std::vector<ui
| |
2152 net_log_.BeginEvent(NetLog::TYPE_SSL_GET_ORIGIN_BOUND_CERT, NULL); | 2154 net_log_.BeginEvent(NetLog::TYPE_SSL_GET_ORIGIN_BOUND_CERT, NULL); |
2153 int error = origin_bound_cert_service_->GetOriginBoundCert( | 2155 int error = origin_bound_cert_service_->GetOriginBoundCert( |
2154 origin, | 2156 origin, |
2155 requested_cert_types, | 2157 requested_cert_types, |
2156 &ob_cert_type_, | 2158 &ob_cert_type_, |
2157 &ob_private_key_, | 2159 &ob_private_key_, |
2158 &ob_cert_, | 2160 &ob_cert_, |
2159 base::Bind(&SSLClientSocketNSS::OnHandshakeIOComplete, | 2161 base::Bind(&SSLClientSocketNSS::OnHandshakeIOComplete, |
2160 base::Unretained(this)), | 2162 base::Unretained(this)), |
2161 &ob_cert_request_handle_); | 2163 &ob_cert_request_handle_); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2194 PRFileDesc* socket, | 2196 PRFileDesc* socket, |
2195 CERTDistNames* ca_names, | 2197 CERTDistNames* ca_names, |
2196 CERTCertList** result_certs, | 2198 CERTCertList** result_certs, |
2197 void** result_private_key, | 2199 void** result_private_key, |
2198 CERTCertificate** result_nss_certificate, | 2200 CERTCertificate** result_nss_certificate, |
2199 SECKEYPrivateKey** result_nss_private_key) { | 2201 SECKEYPrivateKey** result_nss_private_key) { |
2200 SSLClientSocketNSS* that = reinterpret_cast<SSLClientSocketNSS*>(arg); | 2202 SSLClientSocketNSS* that = reinterpret_cast<SSLClientSocketNSS*>(arg); |
2201 | 2203 |
2202 that->net_log_.AddEvent(NetLog::TYPE_SSL_CLIENT_CERT_REQUESTED, NULL); | 2204 that->net_log_.AddEvent(NetLog::TYPE_SSL_CLIENT_CERT_REQUESTED, NULL); |
2203 | 2205 |
2206 const SECItem* cert_types = SSL_GetRequestedClientCertificateTypes(socket); | |
2207 | |
2204 // Check if an origin-bound certificate is requested. | 2208 // Check if an origin-bound certificate is requested. |
2205 if (OriginBoundCertNegotiated(socket)) { | 2209 if (OriginBoundCertNegotiated(socket)) { |
2206 // TODO(mattm): Once NSS supports it, pass the actual requested types. | |
2207 std::vector<uint8> requested_cert_types; | |
2208 requested_cert_types.push_back(CLIENT_CERT_ECDSA_SIGN); | |
2209 requested_cert_types.push_back(CLIENT_CERT_RSA_SIGN); | |
2210 return that->OriginBoundClientAuthHandler( | 2210 return that->OriginBoundClientAuthHandler( |
2211 requested_cert_types, result_nss_certificate, result_nss_private_key); | 2211 cert_types, result_nss_certificate, result_nss_private_key); |
2212 } | 2212 } |
2213 | 2213 |
2214 that->client_auth_cert_needed_ = !that->ssl_config_.send_client_cert; | 2214 that->client_auth_cert_needed_ = !that->ssl_config_.send_client_cert; |
2215 #if defined(OS_WIN) | 2215 #if defined(OS_WIN) |
2216 if (that->ssl_config_.send_client_cert) { | 2216 if (that->ssl_config_.send_client_cert) { |
2217 if (that->ssl_config_.client_cert) { | 2217 if (that->ssl_config_.client_cert) { |
2218 PCCERT_CONTEXT cert_context = | 2218 PCCERT_CONTEXT cert_context = |
2219 that->ssl_config_.client_cert->os_cert_handle(); | 2219 that->ssl_config_.client_cert->os_cert_handle(); |
2220 | 2220 |
2221 HCRYPTPROV_OR_NCRYPT_KEY_HANDLE crypt_prov = 0; | 2221 HCRYPTPROV_OR_NCRYPT_KEY_HANDLE crypt_prov = 0; |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2503 SECStatus SSLClientSocketNSS::ClientAuthHandler( | 2503 SECStatus SSLClientSocketNSS::ClientAuthHandler( |
2504 void* arg, | 2504 void* arg, |
2505 PRFileDesc* socket, | 2505 PRFileDesc* socket, |
2506 CERTDistNames* ca_names, | 2506 CERTDistNames* ca_names, |
2507 CERTCertificate** result_certificate, | 2507 CERTCertificate** result_certificate, |
2508 SECKEYPrivateKey** result_private_key) { | 2508 SECKEYPrivateKey** result_private_key) { |
2509 SSLClientSocketNSS* that = reinterpret_cast<SSLClientSocketNSS*>(arg); | 2509 SSLClientSocketNSS* that = reinterpret_cast<SSLClientSocketNSS*>(arg); |
2510 | 2510 |
2511 that->net_log_.AddEvent(NetLog::TYPE_SSL_CLIENT_CERT_REQUESTED, NULL); | 2511 that->net_log_.AddEvent(NetLog::TYPE_SSL_CLIENT_CERT_REQUESTED, NULL); |
2512 | 2512 |
2513 const SECItem* cert_types = SSL_GetRequestedClientCertificateTypes(socket); | |
2514 | |
2513 // Check if an origin-bound certificate is requested. | 2515 // Check if an origin-bound certificate is requested. |
2514 if (OriginBoundCertNegotiated(socket)) { | 2516 if (OriginBoundCertNegotiated(socket)) { |
2515 // TODO(mattm): Once NSS supports it, pass the actual requested types. | |
2516 std::vector<uint8> requested_cert_types; | |
2517 requested_cert_types.push_back(CLIENT_CERT_ECDSA_SIGN); | |
2518 requested_cert_types.push_back(CLIENT_CERT_RSA_SIGN); | |
2519 return that->OriginBoundClientAuthHandler( | 2517 return that->OriginBoundClientAuthHandler( |
2520 requested_cert_types, result_certificate, result_private_key); | 2518 cert_types, result_certificate, result_private_key); |
2521 } | 2519 } |
2522 | 2520 |
2523 // Regular client certificate requested. | 2521 // Regular client certificate requested. |
2524 that->client_auth_cert_needed_ = !that->ssl_config_.send_client_cert; | 2522 that->client_auth_cert_needed_ = !that->ssl_config_.send_client_cert; |
2525 void* wincx = SSL_RevealPinArg(socket); | 2523 void* wincx = SSL_RevealPinArg(socket); |
2526 | 2524 |
2527 // Second pass: a client certificate should have been selected. | 2525 // Second pass: a client certificate should have been selected. |
2528 if (that->ssl_config_.send_client_cert) { | 2526 if (that->ssl_config_.send_client_cert) { |
2529 if (that->ssl_config_.client_cert) { | 2527 if (that->ssl_config_.client_cert) { |
2530 CERTCertificate* cert = CERT_DupCertificate( | 2528 CERTCertificate* cert = CERT_DupCertificate( |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2656 valid_thread_id_ = base::PlatformThread::CurrentId(); | 2654 valid_thread_id_ = base::PlatformThread::CurrentId(); |
2657 } | 2655 } |
2658 | 2656 |
2659 bool SSLClientSocketNSS::CalledOnValidThread() const { | 2657 bool SSLClientSocketNSS::CalledOnValidThread() const { |
2660 EnsureThreadIdAssigned(); | 2658 EnsureThreadIdAssigned(); |
2661 base::AutoLock auto_lock(lock_); | 2659 base::AutoLock auto_lock(lock_); |
2662 return valid_thread_id_ == base::PlatformThread::CurrentId(); | 2660 return valid_thread_id_ == base::PlatformThread::CurrentId(); |
2663 } | 2661 } |
2664 | 2662 |
2665 } // namespace net | 2663 } // namespace net |
OLD | NEW |