| 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 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 // TODO(wtc,mattm): this is temporary while DBC support is changed into | 375 // TODO(wtc,mattm): this is temporary while DBC support is changed into |
| 376 // Channel ID. | 376 // Channel ID. |
| 377 return false; | 377 return false; |
| 378 } | 378 } |
| 379 | 379 |
| 380 void DestroyCertificates(CERTCertificate** certs, size_t len) { | 380 void DestroyCertificates(CERTCertificate** certs, size_t len) { |
| 381 for (size_t i = 0; i < len; i++) | 381 for (size_t i = 0; i < len; i++) |
| 382 CERT_DestroyCertificate(certs[i]); | 382 CERT_DestroyCertificate(certs[i]); |
| 383 } | 383 } |
| 384 | 384 |
| 385 // Helper function to make it possible to log events from within the |
| 386 // SSLClientSocketNSS::Core. Can't use Bind with BoundNetLog::AddEntry directly |
| 387 // on Windows because it is overloaded. |
| 388 void AddLogEvent(BoundNetLog* net_log, |
| 389 NetLog::EventType event_type, |
| 390 const scoped_refptr<NetLog::EventParameters>& event_params) { |
| 391 if (!net_log) |
| 392 return; |
| 393 net_log->AddEvent(event_type, event_params); |
| 394 } |
| 395 |
| 385 // Helper function to make it easier to call BoundNetLog::AddByteTransferEvent | 396 // Helper function to make it easier to call BoundNetLog::AddByteTransferEvent |
| 386 // from within the SSLClientSocketNSS::Core. | 397 // from within the SSLClientSocketNSS::Core. |
| 387 // AddByteTransferEvent expects to receive a const char*, which within the | 398 // AddByteTransferEvent expects to receive a const char*, which within the |
| 388 // Core is backed by an IOBuffer. If the "const char*" is bound via | 399 // Core is backed by an IOBuffer. If the "const char*" is bound via |
| 389 // base::Bind and posted to another thread, and the IOBuffer that backs that | 400 // base::Bind and posted to another thread, and the IOBuffer that backs that |
| 390 // pointer then goes out of scope on the origin thread, this would result in | 401 // pointer then goes out of scope on the origin thread, this would result in |
| 391 // an invalid read of a stale pointer. | 402 // an invalid read of a stale pointer. |
| 392 // Instead, provide a signature that accepts an IOBuffer*, so that a reference | 403 // Instead, provide a signature that accepts an IOBuffer*, so that a reference |
| 393 // to the owning IOBuffer can be bound to the Callback. This ensures that the | 404 // to the owning IOBuffer can be bound to the Callback. This ensures that the |
| 394 // IOBuffer will stay alive long enough to cross threads if needed. | 405 // IOBuffer will stay alive long enough to cross threads if needed. |
| (...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1255 CERTDistNames* ca_names, | 1266 CERTDistNames* ca_names, |
| 1256 CERTCertList** result_certs, | 1267 CERTCertList** result_certs, |
| 1257 void** result_private_key, | 1268 void** result_private_key, |
| 1258 CERTCertificate** result_nss_certificate, | 1269 CERTCertificate** result_nss_certificate, |
| 1259 SECKEYPrivateKey** result_nss_private_key) { | 1270 SECKEYPrivateKey** result_nss_private_key) { |
| 1260 Core* core = reinterpret_cast<Core*>(arg); | 1271 Core* core = reinterpret_cast<Core*>(arg); |
| 1261 DCHECK(core->OnNSSTaskRunner()); | 1272 DCHECK(core->OnNSSTaskRunner()); |
| 1262 | 1273 |
| 1263 core->PostOrRunCallback( | 1274 core->PostOrRunCallback( |
| 1264 FROM_HERE, | 1275 FROM_HERE, |
| 1265 base::Bind(&BoundNetLog::AddEvent, core->weak_net_log_, | 1276 base::Bind(&AddLogEvent, core->weak_net_log_, |
| 1266 NetLog::TYPE_SSL_CLIENT_CERT_REQUESTED, | 1277 NetLog::TYPE_SSL_CLIENT_CERT_REQUESTED, |
| 1267 scoped_refptr<NetLog::EventParameters>())); | 1278 scoped_refptr<NetLog::EventParameters>())); |
| 1268 | 1279 |
| 1269 const SECItem* cert_types = SSL_GetRequestedClientCertificateTypes(socket); | 1280 const SECItem* cert_types = SSL_GetRequestedClientCertificateTypes(socket); |
| 1270 | 1281 |
| 1271 // Check if a domain-bound certificate is requested. | 1282 // Check if a domain-bound certificate is requested. |
| 1272 if (DomainBoundCertNegotiated(socket)) { | 1283 if (DomainBoundCertNegotiated(socket)) { |
| 1273 return core->DomainBoundClientAuthHandler(cert_types, | 1284 return core->DomainBoundClientAuthHandler(cert_types, |
| 1274 result_nss_certificate, | 1285 result_nss_certificate, |
| 1275 result_nss_private_key); | 1286 result_nss_private_key); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1302 | 1313 |
| 1303 // TODO(rsleevi): Error checking for NSS allocation errors. | 1314 // TODO(rsleevi): Error checking for NSS allocation errors. |
| 1304 CERTCertDBHandle* db_handle = CERT_GetDefaultCertDB(); | 1315 CERTCertDBHandle* db_handle = CERT_GetDefaultCertDB(); |
| 1305 CERTCertificate* user_cert = CERT_NewTempCertificate( | 1316 CERTCertificate* user_cert = CERT_NewTempCertificate( |
| 1306 db_handle, &der_cert, NULL, PR_FALSE, PR_TRUE); | 1317 db_handle, &der_cert, NULL, PR_FALSE, PR_TRUE); |
| 1307 if (!user_cert) { | 1318 if (!user_cert) { |
| 1308 // Importing the certificate can fail for reasons including a serial | 1319 // Importing the certificate can fail for reasons including a serial |
| 1309 // number collision. See crbug.com/97355. | 1320 // number collision. See crbug.com/97355. |
| 1310 core->PostOrRunCallback( | 1321 core->PostOrRunCallback( |
| 1311 FROM_HERE, | 1322 FROM_HERE, |
| 1312 base::Bind(&BoundNetLog::AddEvent, core->weak_net_log_, | 1323 base::Bind(&AddLogEvent, core->weak_net_log_, |
| 1313 NetLog::TYPE_SSL_CLIENT_CERT_PROVIDED, | 1324 NetLog::TYPE_SSL_CLIENT_CERT_PROVIDED, |
| 1314 make_scoped_refptr( | 1325 make_scoped_refptr( |
| 1315 new NetLogIntegerParameter("cert_count", 0)))); | 1326 new NetLogIntegerParameter("cert_count", 0)))); |
| 1316 return SECFailure; | 1327 return SECFailure; |
| 1317 } | 1328 } |
| 1318 CERTCertList* cert_chain = CERT_NewCertList(); | 1329 CERTCertList* cert_chain = CERT_NewCertList(); |
| 1319 CERT_AddCertToListTail(cert_chain, user_cert); | 1330 CERT_AddCertToListTail(cert_chain, user_cert); |
| 1320 | 1331 |
| 1321 // Add the intermediates. | 1332 // Add the intermediates. |
| 1322 X509Certificate::OSCertHandles intermediates = | 1333 X509Certificate::OSCertHandles intermediates = |
| 1323 core->ssl_config_.client_cert->GetIntermediateCertificates(); | 1334 core->ssl_config_.client_cert->GetIntermediateCertificates(); |
| 1324 for (X509Certificate::OSCertHandles::const_iterator it = | 1335 for (X509Certificate::OSCertHandles::const_iterator it = |
| 1325 intermediates.begin(); it != intermediates.end(); ++it) { | 1336 intermediates.begin(); it != intermediates.end(); ++it) { |
| 1326 der_cert.data = (*it)->pbCertEncoded; | 1337 der_cert.data = (*it)->pbCertEncoded; |
| 1327 der_cert.len = (*it)->cbCertEncoded; | 1338 der_cert.len = (*it)->cbCertEncoded; |
| 1328 | 1339 |
| 1329 CERTCertificate* intermediate = CERT_NewTempCertificate( | 1340 CERTCertificate* intermediate = CERT_NewTempCertificate( |
| 1330 db_handle, &der_cert, NULL, PR_FALSE, PR_TRUE); | 1341 db_handle, &der_cert, NULL, PR_FALSE, PR_TRUE); |
| 1331 if (!intermediate) { | 1342 if (!intermediate) { |
| 1332 CERT_DestroyCertList(cert_chain); | 1343 CERT_DestroyCertList(cert_chain); |
| 1333 core->PostOrRunCallback( | 1344 core->PostOrRunCallback( |
| 1334 FROM_HERE, | 1345 FROM_HERE, |
| 1335 base::Bind(&BoundNetLog::AddEvent, core->weak_net_log_, | 1346 base::Bind(&AddLogEvent, core->weak_net_log_, |
| 1336 NetLog::TYPE_SSL_CLIENT_CERT_PROVIDED, | 1347 NetLog::TYPE_SSL_CLIENT_CERT_PROVIDED, |
| 1337 make_scoped_refptr( | 1348 make_scoped_refptr( |
| 1338 new NetLogIntegerParameter("cert_count", 0)))); | 1349 new NetLogIntegerParameter("cert_count", 0)))); |
| 1339 return SECFailure; | 1350 return SECFailure; |
| 1340 } | 1351 } |
| 1341 CERT_AddCertToListTail(cert_chain, intermediate); | 1352 CERT_AddCertToListTail(cert_chain, intermediate); |
| 1342 } | 1353 } |
| 1343 PCERT_KEY_CONTEXT key_context = reinterpret_cast<PCERT_KEY_CONTEXT>( | 1354 PCERT_KEY_CONTEXT key_context = reinterpret_cast<PCERT_KEY_CONTEXT>( |
| 1344 PORT_ZAlloc(sizeof(CERT_KEY_CONTEXT))); | 1355 PORT_ZAlloc(sizeof(CERT_KEY_CONTEXT))); |
| 1345 key_context->cbSize = sizeof(*key_context); | 1356 key_context->cbSize = sizeof(*key_context); |
| 1346 // NSS will free this context when no longer in use, but the | 1357 // NSS will free this context when no longer in use, but the |
| 1347 // |must_free| result from CryptAcquireCertificatePrivateKey was false | 1358 // |must_free| result from CryptAcquireCertificatePrivateKey was false |
| 1348 // so we increment the refcount to negate NSS's future decrement. | 1359 // so we increment the refcount to negate NSS's future decrement. |
| 1349 CryptContextAddRef(crypt_prov, NULL, 0); | 1360 CryptContextAddRef(crypt_prov, NULL, 0); |
| 1350 key_context->hCryptProv = crypt_prov; | 1361 key_context->hCryptProv = crypt_prov; |
| 1351 key_context->dwKeySpec = key_spec; | 1362 key_context->dwKeySpec = key_spec; |
| 1352 *result_private_key = key_context; | 1363 *result_private_key = key_context; |
| 1353 *result_certs = cert_chain; | 1364 *result_certs = cert_chain; |
| 1354 | 1365 |
| 1355 int cert_count = 1 + intermediates.size(); | 1366 int cert_count = 1 + intermediates.size(); |
| 1356 core->PostOrRunCallback( | 1367 core->PostOrRunCallback( |
| 1357 FROM_HERE, | 1368 FROM_HERE, |
| 1358 base::Bind(&BoundNetLog::AddEvent, core->weak_net_log_, | 1369 base::Bind(&AddLogEvent, core->weak_net_log_, |
| 1359 NetLog::TYPE_SSL_CLIENT_CERT_PROVIDED, | 1370 NetLog::TYPE_SSL_CLIENT_CERT_PROVIDED, |
| 1360 make_scoped_refptr( | 1371 make_scoped_refptr( |
| 1361 new NetLogIntegerParameter("cert_count", | 1372 new NetLogIntegerParameter("cert_count", |
| 1362 cert_count)))); | 1373 cert_count)))); |
| 1363 return SECSuccess; | 1374 return SECSuccess; |
| 1364 } | 1375 } |
| 1365 LOG(WARNING) << "Client cert found without private key"; | 1376 LOG(WARNING) << "Client cert found without private key"; |
| 1366 } | 1377 } |
| 1367 | 1378 |
| 1368 // Send no client certificate. | 1379 // Send no client certificate. |
| 1369 core->PostOrRunCallback( | 1380 core->PostOrRunCallback( |
| 1370 FROM_HERE, | 1381 FROM_HERE, |
| 1371 base::Bind(&BoundNetLog::AddEvent, core->weak_net_log_, | 1382 base::Bind(&AddLogEvent, core->weak_net_log_, |
| 1372 NetLog::TYPE_SSL_CLIENT_CERT_PROVIDED, | 1383 NetLog::TYPE_SSL_CLIENT_CERT_PROVIDED, |
| 1373 make_scoped_refptr( | 1384 make_scoped_refptr( |
| 1374 new NetLogIntegerParameter("cert_count", 0)))); | 1385 new NetLogIntegerParameter("cert_count", 0)))); |
| 1375 return SECFailure; | 1386 return SECFailure; |
| 1376 } | 1387 } |
| 1377 | 1388 |
| 1378 core->nss_handshake_state_.client_certs.clear(); | 1389 core->nss_handshake_state_.client_certs.clear(); |
| 1379 | 1390 |
| 1380 std::vector<CERT_NAME_BLOB> issuer_list(ca_names->nnames); | 1391 std::vector<CERT_NAME_BLOB> issuer_list(ca_names->nnames); |
| 1381 for (int i = 0; i < ca_names->nnames; ++i) { | 1392 for (int i = 0; i < ca_names->nnames; ++i) { |
| 1382 issuer_list[i].cbData = ca_names->names[i].len; | 1393 issuer_list[i].cbData = ca_names->names[i].len; |
| 1383 issuer_list[i].pbData = ca_names->names[i].data; | 1394 issuer_list[i].pbData = ca_names->names[i].data; |
| 1384 } | 1395 } |
| 1385 | 1396 |
| 1386 // Client certificates of the user are in the "MY" system certificate store. | 1397 // Client certificates of the user are in the "MY" system certificate store. |
| 1387 HCERTSTORE my_cert_store = CertOpenSystemStore(NULL, L"MY"); | 1398 HCERTSTORE my_cert_store = CertOpenSystemStore(NULL, L"MY"); |
| 1388 if (!my_cert_store) { | 1399 if (!my_cert_store) { |
| 1389 PLOG(ERROR) << "Could not open the \"MY\" system certificate store"; | 1400 PLOG(ERROR) << "Could not open the \"MY\" system certificate store"; |
| 1390 | 1401 |
| 1391 core->PostOrRunCallback( | 1402 core->PostOrRunCallback( |
| 1392 FROM_HERE, | 1403 FROM_HERE, |
| 1393 base::Bind(&BoundNetLog::AddEvent, core->weak_net_log_, | 1404 base::Bind(&AddLogEvent, core->weak_net_log_, |
| 1394 NetLog::TYPE_SSL_CLIENT_CERT_PROVIDED, | 1405 NetLog::TYPE_SSL_CLIENT_CERT_PROVIDED, |
| 1395 make_scoped_refptr( | 1406 make_scoped_refptr( |
| 1396 new NetLogIntegerParameter("cert_count", 0)))); | 1407 new NetLogIntegerParameter("cert_count", 0)))); |
| 1397 return SECFailure; | 1408 return SECFailure; |
| 1398 } | 1409 } |
| 1399 | 1410 |
| 1400 // Enumerate the client certificates. | 1411 // Enumerate the client certificates. |
| 1401 CERT_CHAIN_FIND_BY_ISSUER_PARA find_by_issuer_para; | 1412 CERT_CHAIN_FIND_BY_ISSUER_PARA find_by_issuer_para; |
| 1402 memset(&find_by_issuer_para, 0, sizeof(find_by_issuer_para)); | 1413 memset(&find_by_issuer_para, 0, sizeof(find_by_issuer_para)); |
| 1403 find_by_issuer_para.cbSize = sizeof(find_by_issuer_para); | 1414 find_by_issuer_para.cbSize = sizeof(find_by_issuer_para); |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1528 } | 1539 } |
| 1529 } | 1540 } |
| 1530 if (os_error == noErr) { | 1541 if (os_error == noErr) { |
| 1531 int cert_count = 0; | 1542 int cert_count = 0; |
| 1532 if (chain) { | 1543 if (chain) { |
| 1533 cert_count = CFArrayGetCount(chain); | 1544 cert_count = CFArrayGetCount(chain); |
| 1534 CFRelease(chain); | 1545 CFRelease(chain); |
| 1535 } | 1546 } |
| 1536 core->PostOrRunCallback( | 1547 core->PostOrRunCallback( |
| 1537 FROM_HERE, | 1548 FROM_HERE, |
| 1538 base::Bind(&BoundNetLog::AddEvent, core->weak_net_log_, | 1549 base::Bind(&AddLogEvent, core->weak_net_log_, |
| 1539 NetLog::TYPE_SSL_CLIENT_CERT_PROVIDED, | 1550 NetLog::TYPE_SSL_CLIENT_CERT_PROVIDED, |
| 1540 make_scoped_refptr( | 1551 make_scoped_refptr( |
| 1541 new NetLogIntegerParameter("cert_count", | 1552 new NetLogIntegerParameter("cert_count", |
| 1542 cert_count)))); | 1553 cert_count)))); |
| 1543 return SECSuccess; | 1554 return SECSuccess; |
| 1544 } | 1555 } |
| 1545 OSSTATUS_LOG(WARNING, os_error) | 1556 OSSTATUS_LOG(WARNING, os_error) |
| 1546 << "Client cert found, but could not be used"; | 1557 << "Client cert found, but could not be used"; |
| 1547 if (*result_certs) { | 1558 if (*result_certs) { |
| 1548 CERT_DestroyCertList(*result_certs); | 1559 CERT_DestroyCertList(*result_certs); |
| 1549 *result_certs = NULL; | 1560 *result_certs = NULL; |
| 1550 } | 1561 } |
| 1551 if (*result_private_key) | 1562 if (*result_private_key) |
| 1552 *result_private_key = NULL; | 1563 *result_private_key = NULL; |
| 1553 if (private_key) | 1564 if (private_key) |
| 1554 CFRelease(private_key); | 1565 CFRelease(private_key); |
| 1555 if (chain) | 1566 if (chain) |
| 1556 CFRelease(chain); | 1567 CFRelease(chain); |
| 1557 } | 1568 } |
| 1558 | 1569 |
| 1559 // Send no client certificate. | 1570 // Send no client certificate. |
| 1560 core->PostOrRunCallback( | 1571 core->PostOrRunCallback( |
| 1561 FROM_HERE, | 1572 FROM_HERE, |
| 1562 base::Bind(&BoundNetLog::AddEvent, core->weak_net_log_, | 1573 base::Bind(&AddLogEvent, core->weak_net_log_, |
| 1563 NetLog::TYPE_SSL_CLIENT_CERT_PROVIDED, | 1574 NetLog::TYPE_SSL_CLIENT_CERT_PROVIDED, |
| 1564 make_scoped_refptr( | 1575 make_scoped_refptr( |
| 1565 new NetLogIntegerParameter("cert_count", 0)))); | 1576 new NetLogIntegerParameter("cert_count", 0)))); |
| 1566 return SECFailure; | 1577 return SECFailure; |
| 1567 } | 1578 } |
| 1568 | 1579 |
| 1569 core->nss_handshake_state_.client_certs.clear(); | 1580 core->nss_handshake_state_.client_certs.clear(); |
| 1570 | 1581 |
| 1571 // First, get the cert issuer names allowed by the server. | 1582 // First, get the cert issuer names allowed by the server. |
| 1572 std::vector<CertPrincipal> valid_issuers; | 1583 std::vector<CertPrincipal> valid_issuers; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1607 void* arg, | 1618 void* arg, |
| 1608 PRFileDesc* socket, | 1619 PRFileDesc* socket, |
| 1609 CERTDistNames* ca_names, | 1620 CERTDistNames* ca_names, |
| 1610 CERTCertificate** result_certificate, | 1621 CERTCertificate** result_certificate, |
| 1611 SECKEYPrivateKey** result_private_key) { | 1622 SECKEYPrivateKey** result_private_key) { |
| 1612 Core* core = reinterpret_cast<Core*>(arg); | 1623 Core* core = reinterpret_cast<Core*>(arg); |
| 1613 DCHECK(core->OnNSSTaskRunner()); | 1624 DCHECK(core->OnNSSTaskRunner()); |
| 1614 | 1625 |
| 1615 core->PostOrRunCallback( | 1626 core->PostOrRunCallback( |
| 1616 FROM_HERE, | 1627 FROM_HERE, |
| 1617 base::Bind(&BoundNetLog::AddEvent, core->weak_net_log_, | 1628 base::Bind(&AddLogEvent, core->weak_net_log_, |
| 1618 NetLog::TYPE_SSL_CLIENT_CERT_REQUESTED, | 1629 NetLog::TYPE_SSL_CLIENT_CERT_REQUESTED, |
| 1619 scoped_refptr<NetLog::EventParameters>())); | 1630 scoped_refptr<NetLog::EventParameters>())); |
| 1620 | 1631 |
| 1621 const SECItem* cert_types = SSL_GetRequestedClientCertificateTypes(socket); | 1632 const SECItem* cert_types = SSL_GetRequestedClientCertificateTypes(socket); |
| 1622 | 1633 |
| 1623 // Check if a domain-bound certificate is requested. | 1634 // Check if a domain-bound certificate is requested. |
| 1624 if (DomainBoundCertNegotiated(socket)) { | 1635 if (DomainBoundCertNegotiated(socket)) { |
| 1625 return core->DomainBoundClientAuthHandler( | 1636 return core->DomainBoundClientAuthHandler( |
| 1626 cert_types, result_certificate, result_private_key); | 1637 cert_types, result_certificate, result_private_key); |
| 1627 } | 1638 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1639 if (privkey) { | 1650 if (privkey) { |
| 1640 // TODO(jsorianopastor): We should wait for server certificate | 1651 // TODO(jsorianopastor): We should wait for server certificate |
| 1641 // verification before sending our credentials. See | 1652 // verification before sending our credentials. See |
| 1642 // http://crbug.com/13934. | 1653 // http://crbug.com/13934. |
| 1643 *result_certificate = cert; | 1654 *result_certificate = cert; |
| 1644 *result_private_key = privkey; | 1655 *result_private_key = privkey; |
| 1645 // A cert_count of -1 means the number of certificates is unknown. | 1656 // A cert_count of -1 means the number of certificates is unknown. |
| 1646 // NSS will construct the certificate chain. | 1657 // NSS will construct the certificate chain. |
| 1647 core->PostOrRunCallback( | 1658 core->PostOrRunCallback( |
| 1648 FROM_HERE, | 1659 FROM_HERE, |
| 1649 base::Bind(&BoundNetLog::AddEvent, core->weak_net_log_, | 1660 base::Bind(&AddLogEvent, core->weak_net_log_, |
| 1650 NetLog::TYPE_SSL_CLIENT_CERT_PROVIDED, | 1661 NetLog::TYPE_SSL_CLIENT_CERT_PROVIDED, |
| 1651 make_scoped_refptr( | 1662 make_scoped_refptr( |
| 1652 new NetLogIntegerParameter("cert_count", -1)))); | 1663 new NetLogIntegerParameter("cert_count", -1)))); |
| 1653 | 1664 |
| 1654 return SECSuccess; | 1665 return SECSuccess; |
| 1655 } | 1666 } |
| 1656 LOG(WARNING) << "Client cert found without private key"; | 1667 LOG(WARNING) << "Client cert found without private key"; |
| 1657 } | 1668 } |
| 1658 // Send no client certificate. | 1669 // Send no client certificate. |
| 1659 core->PostOrRunCallback( | 1670 core->PostOrRunCallback( |
| 1660 FROM_HERE, | 1671 FROM_HERE, |
| 1661 base::Bind(&BoundNetLog::AddEvent, core->weak_net_log_, | 1672 base::Bind(&AddLogEvent, core->weak_net_log_, |
| 1662 NetLog::TYPE_SSL_CLIENT_CERT_PROVIDED, | 1673 NetLog::TYPE_SSL_CLIENT_CERT_PROVIDED, |
| 1663 make_scoped_refptr( | 1674 make_scoped_refptr( |
| 1664 new NetLogIntegerParameter("cert_count", 0)))); | 1675 new NetLogIntegerParameter("cert_count", 0)))); |
| 1665 return SECFailure; | 1676 return SECFailure; |
| 1666 } | 1677 } |
| 1667 | 1678 |
| 1668 core->nss_handshake_state_.client_certs.clear(); | 1679 core->nss_handshake_state_.client_certs.clear(); |
| 1669 | 1680 |
| 1670 // Iterate over all client certificates. | 1681 // Iterate over all client certificates. |
| 1671 CERTCertList* client_certs = CERT_FindUserCertsByUsage( | 1682 CERTCertList* client_certs = CERT_FindUserCertsByUsage( |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1902 DCHECK_EQ(STATE_NONE, next_handshake_state_); | 1913 DCHECK_EQ(STATE_NONE, next_handshake_state_); |
| 1903 | 1914 |
| 1904 if (result < 0) | 1915 if (result < 0) |
| 1905 return result; | 1916 return result; |
| 1906 | 1917 |
| 1907 if (!nss_bufs_) { | 1918 if (!nss_bufs_) { |
| 1908 LOG(DFATAL) << "!nss_bufs_"; | 1919 LOG(DFATAL) << "!nss_bufs_"; |
| 1909 int rv = ERR_UNEXPECTED; | 1920 int rv = ERR_UNEXPECTED; |
| 1910 PostOrRunCallback( | 1921 PostOrRunCallback( |
| 1911 FROM_HERE, | 1922 FROM_HERE, |
| 1912 base::Bind(&BoundNetLog::AddEvent, weak_net_log_, | 1923 base::Bind(&AddLogEvent, weak_net_log_, |
| 1913 NetLog::TYPE_SSL_READ_ERROR, | 1924 NetLog::TYPE_SSL_READ_ERROR, |
| 1914 make_scoped_refptr(new SSLErrorParams(rv, 0)))); | 1925 make_scoped_refptr(new SSLErrorParams(rv, 0)))); |
| 1915 return rv; | 1926 return rv; |
| 1916 } | 1927 } |
| 1917 | 1928 |
| 1918 bool network_moved; | 1929 bool network_moved; |
| 1919 int rv; | 1930 int rv; |
| 1920 do { | 1931 do { |
| 1921 rv = DoPayloadRead(); | 1932 rv = DoPayloadRead(); |
| 1922 network_moved = DoTransportIO(); | 1933 network_moved = DoTransportIO(); |
| 1923 } while (rv == ERR_IO_PENDING && network_moved); | 1934 } while (rv == ERR_IO_PENDING && network_moved); |
| 1924 | 1935 |
| 1925 return rv; | 1936 return rv; |
| 1926 } | 1937 } |
| 1927 | 1938 |
| 1928 int SSLClientSocketNSS::Core::DoWriteLoop(int result) { | 1939 int SSLClientSocketNSS::Core::DoWriteLoop(int result) { |
| 1929 DCHECK(OnNSSTaskRunner()); | 1940 DCHECK(OnNSSTaskRunner()); |
| 1930 DCHECK(handshake_callback_called_); | 1941 DCHECK(handshake_callback_called_); |
| 1931 DCHECK_EQ(STATE_NONE, next_handshake_state_); | 1942 DCHECK_EQ(STATE_NONE, next_handshake_state_); |
| 1932 | 1943 |
| 1933 if (result < 0) | 1944 if (result < 0) |
| 1934 return result; | 1945 return result; |
| 1935 | 1946 |
| 1936 if (!nss_bufs_) { | 1947 if (!nss_bufs_) { |
| 1937 LOG(DFATAL) << "!nss_bufs_"; | 1948 LOG(DFATAL) << "!nss_bufs_"; |
| 1938 int rv = ERR_UNEXPECTED; | 1949 int rv = ERR_UNEXPECTED; |
| 1939 PostOrRunCallback( | 1950 PostOrRunCallback( |
| 1940 FROM_HERE, | 1951 FROM_HERE, |
| 1941 base::Bind(&BoundNetLog::AddEvent, weak_net_log_, | 1952 base::Bind(&AddLogEvent, weak_net_log_, |
| 1942 NetLog::TYPE_SSL_READ_ERROR, | 1953 NetLog::TYPE_SSL_READ_ERROR, |
| 1943 make_scoped_refptr(new SSLErrorParams(rv, 0)))); | 1954 make_scoped_refptr(new SSLErrorParams(rv, 0)))); |
| 1944 return rv; | 1955 return rv; |
| 1945 } | 1956 } |
| 1946 | 1957 |
| 1947 bool network_moved; | 1958 bool network_moved; |
| 1948 int rv; | 1959 int rv; |
| 1949 do { | 1960 do { |
| 1950 rv = DoPayloadWrite(); | 1961 rv = DoPayloadWrite(); |
| 1951 network_moved = DoTransportIO(); | 1962 network_moved = DoTransportIO(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1966 // code so that the higher level code will attempt to delete the socket and | 1977 // code so that the higher level code will attempt to delete the socket and |
| 1967 // redo the handshake. | 1978 // redo the handshake. |
| 1968 if (client_auth_cert_needed_) { | 1979 if (client_auth_cert_needed_) { |
| 1969 if (domain_bound_cert_xtn_negotiated_) { | 1980 if (domain_bound_cert_xtn_negotiated_) { |
| 1970 GotoState(STATE_GET_DOMAIN_BOUND_CERT_COMPLETE); | 1981 GotoState(STATE_GET_DOMAIN_BOUND_CERT_COMPLETE); |
| 1971 net_error = ERR_IO_PENDING; | 1982 net_error = ERR_IO_PENDING; |
| 1972 } else { | 1983 } else { |
| 1973 net_error = ERR_SSL_CLIENT_AUTH_CERT_NEEDED; | 1984 net_error = ERR_SSL_CLIENT_AUTH_CERT_NEEDED; |
| 1974 PostOrRunCallback( | 1985 PostOrRunCallback( |
| 1975 FROM_HERE, | 1986 FROM_HERE, |
| 1976 base::Bind(&BoundNetLog::AddEvent, weak_net_log_, | 1987 base::Bind(&AddLogEvent, weak_net_log_, |
| 1977 NetLog::TYPE_SSL_HANDSHAKE_ERROR, | 1988 NetLog::TYPE_SSL_HANDSHAKE_ERROR, |
| 1978 make_scoped_refptr(new SSLErrorParams(net_error, 0)))); | 1989 make_scoped_refptr(new SSLErrorParams(net_error, 0)))); |
| 1979 | 1990 |
| 1980 // If the handshake already succeeded (because the server requests but | 1991 // If the handshake already succeeded (because the server requests but |
| 1981 // doesn't require a client cert), we need to invalidate the SSL session | 1992 // doesn't require a client cert), we need to invalidate the SSL session |
| 1982 // so that we won't try to resume the non-client-authenticated session in | 1993 // so that we won't try to resume the non-client-authenticated session in |
| 1983 // the next handshake. This will cause the server to ask for a client | 1994 // the next handshake. This will cause the server to ask for a client |
| 1984 // cert again. | 1995 // cert again. |
| 1985 if (rv == SECSuccess && SSL_InvalidateSession(nss_fd_) != SECSuccess) | 1996 if (rv == SECSuccess && SSL_InvalidateSession(nss_fd_) != SECSuccess) |
| 1986 LOG(WARNING) << "Couldn't invalidate SSL session: " << PR_GetError(); | 1997 LOG(WARNING) << "Couldn't invalidate SSL session: " << PR_GetError(); |
| 1987 } | 1998 } |
| 1988 } else if (rv == SECSuccess) { | 1999 } else if (rv == SECSuccess) { |
| 1989 if (!handshake_callback_called_) { | 2000 if (!handshake_callback_called_) { |
| 1990 // Workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=562434 - | 2001 // Workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=562434 - |
| 1991 // SSL_ForceHandshake returned SECSuccess prematurely. | 2002 // SSL_ForceHandshake returned SECSuccess prematurely. |
| 1992 rv = SECFailure; | 2003 rv = SECFailure; |
| 1993 net_error = ERR_SSL_PROTOCOL_ERROR; | 2004 net_error = ERR_SSL_PROTOCOL_ERROR; |
| 1994 PostOrRunCallback( | 2005 PostOrRunCallback( |
| 1995 FROM_HERE, | 2006 FROM_HERE, |
| 1996 base::Bind(&BoundNetLog::AddEvent, weak_net_log_, | 2007 base::Bind(&AddLogEvent, weak_net_log_, |
| 1997 NetLog::TYPE_SSL_HANDSHAKE_ERROR, | 2008 NetLog::TYPE_SSL_HANDSHAKE_ERROR, |
| 1998 make_scoped_refptr( | 2009 make_scoped_refptr( |
| 1999 new SSLErrorParams(net_error, 0)))); | 2010 new SSLErrorParams(net_error, 0)))); |
| 2000 } else { | 2011 } else { |
| 2001 #if defined(SSL_ENABLE_OCSP_STAPLING) | 2012 #if defined(SSL_ENABLE_OCSP_STAPLING) |
| 2002 // TODO(agl): figure out how to plumb an OCSP response into the Mac | 2013 // TODO(agl): figure out how to plumb an OCSP response into the Mac |
| 2003 // system library and update IsOCSPStaplingSupported for Mac. | 2014 // system library and update IsOCSPStaplingSupported for Mac. |
| 2004 if (!nss_handshake_state_.predicted_cert_chain_correct && | 2015 if (!nss_handshake_state_.predicted_cert_chain_correct && |
| 2005 IsOCSPStaplingSupported()) { | 2016 IsOCSPStaplingSupported()) { |
| 2006 unsigned int len = 0; | 2017 unsigned int len = 0; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2047 } else { | 2058 } else { |
| 2048 PRErrorCode prerr = PR_GetError(); | 2059 PRErrorCode prerr = PR_GetError(); |
| 2049 net_error = HandleNSSError(prerr, true); | 2060 net_error = HandleNSSError(prerr, true); |
| 2050 | 2061 |
| 2051 // If not done, stay in this state | 2062 // If not done, stay in this state |
| 2052 if (net_error == ERR_IO_PENDING) { | 2063 if (net_error == ERR_IO_PENDING) { |
| 2053 GotoState(STATE_HANDSHAKE); | 2064 GotoState(STATE_HANDSHAKE); |
| 2054 } else { | 2065 } else { |
| 2055 PostOrRunCallback( | 2066 PostOrRunCallback( |
| 2056 FROM_HERE, | 2067 FROM_HERE, |
| 2057 base::Bind(&BoundNetLog::AddEvent, weak_net_log_, | 2068 base::Bind(&AddLogEvent, weak_net_log_, |
| 2058 NetLog::TYPE_SSL_HANDSHAKE_ERROR, | 2069 NetLog::TYPE_SSL_HANDSHAKE_ERROR, |
| 2059 make_scoped_refptr( | 2070 make_scoped_refptr( |
| 2060 new SSLErrorParams(net_error, prerr)))); | 2071 new SSLErrorParams(net_error, prerr)))); |
| 2061 } | 2072 } |
| 2062 } | 2073 } |
| 2063 | 2074 |
| 2064 return net_error; | 2075 return net_error; |
| 2065 } | 2076 } |
| 2066 | 2077 |
| 2067 int SSLClientSocketNSS::Core::DoGetDBCertComplete(int result) { | 2078 int SSLClientSocketNSS::Core::DoGetDBCertComplete(int result) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2088 SECKEYPrivateKey* key; | 2099 SECKEYPrivateKey* key; |
| 2089 int error = ImportDBCertAndKey(&cert, &key); | 2100 int error = ImportDBCertAndKey(&cert, &key); |
| 2090 if (error != OK) | 2101 if (error != OK) |
| 2091 return error; | 2102 return error; |
| 2092 | 2103 |
| 2093 CERTCertificateList* cert_chain = | 2104 CERTCertificateList* cert_chain = |
| 2094 CERT_CertChainFromCert(cert, certUsageSSLClient, PR_FALSE); | 2105 CERT_CertChainFromCert(cert, certUsageSSLClient, PR_FALSE); |
| 2095 | 2106 |
| 2096 PostOrRunCallback( | 2107 PostOrRunCallback( |
| 2097 FROM_HERE, | 2108 FROM_HERE, |
| 2098 base::Bind(&BoundNetLog::AddEvent, weak_net_log_, | 2109 base::Bind(&AddLogEvent, weak_net_log_, |
| 2099 NetLog::TYPE_SSL_CLIENT_CERT_PROVIDED, | 2110 NetLog::TYPE_SSL_CLIENT_CERT_PROVIDED, |
| 2100 make_scoped_refptr( | 2111 make_scoped_refptr( |
| 2101 new NetLogIntegerParameter("cert_count", | 2112 new NetLogIntegerParameter("cert_count", |
| 2102 cert_chain->len)))); | 2113 cert_chain->len)))); |
| 2103 | 2114 |
| 2104 rv = SSL_RestartHandshakeAfterCertReq(nss_fd_, cert, key, cert_chain); | 2115 rv = SSL_RestartHandshakeAfterCertReq(nss_fd_, cert, key, cert_chain); |
| 2105 if (rv != SECSuccess) | 2116 if (rv != SECSuccess) |
| 2106 return MapNSSError(PORT_GetError()); | 2117 return MapNSSError(PORT_GetError()); |
| 2107 | 2118 |
| 2108 GotoState(STATE_HANDSHAKE); | 2119 GotoState(STATE_HANDSHAKE); |
| 2109 return OK; | 2120 return OK; |
| 2110 } | 2121 } |
| 2111 | 2122 |
| 2112 int SSLClientSocketNSS::Core::DoPayloadRead() { | 2123 int SSLClientSocketNSS::Core::DoPayloadRead() { |
| 2113 DCHECK(OnNSSTaskRunner()); | 2124 DCHECK(OnNSSTaskRunner()); |
| 2114 DCHECK(user_read_buf_); | 2125 DCHECK(user_read_buf_); |
| 2115 DCHECK_GT(user_read_buf_len_, 0); | 2126 DCHECK_GT(user_read_buf_len_, 0); |
| 2116 | 2127 |
| 2117 int rv = PR_Read(nss_fd_, user_read_buf_->data(), user_read_buf_len_); | 2128 int rv = PR_Read(nss_fd_, user_read_buf_->data(), user_read_buf_len_); |
| 2118 if (client_auth_cert_needed_) { | 2129 if (client_auth_cert_needed_) { |
| 2119 // We don't need to invalidate the non-client-authenticated SSL session | 2130 // We don't need to invalidate the non-client-authenticated SSL session |
| 2120 // because the server will renegotiate anyway. | 2131 // because the server will renegotiate anyway. |
| 2121 rv = ERR_SSL_CLIENT_AUTH_CERT_NEEDED; | 2132 rv = ERR_SSL_CLIENT_AUTH_CERT_NEEDED; |
| 2122 PostOrRunCallback( | 2133 PostOrRunCallback( |
| 2123 FROM_HERE, | 2134 FROM_HERE, |
| 2124 base::Bind(&BoundNetLog::AddEvent, weak_net_log_, | 2135 base::Bind(&AddLogEvent, weak_net_log_, |
| 2125 NetLog::TYPE_SSL_READ_ERROR, | 2136 NetLog::TYPE_SSL_READ_ERROR, |
| 2126 make_scoped_refptr(new SSLErrorParams(rv, 0)))); | 2137 make_scoped_refptr(new SSLErrorParams(rv, 0)))); |
| 2127 return rv; | 2138 return rv; |
| 2128 } | 2139 } |
| 2129 if (rv >= 0) { | 2140 if (rv >= 0) { |
| 2130 PostOrRunCallback( | 2141 PostOrRunCallback( |
| 2131 FROM_HERE, | 2142 FROM_HERE, |
| 2132 base::Bind(&LogByteTransferEvent, weak_net_log_, | 2143 base::Bind(&LogByteTransferEvent, weak_net_log_, |
| 2133 NetLog::TYPE_SSL_SOCKET_BYTES_RECEIVED, rv, | 2144 NetLog::TYPE_SSL_SOCKET_BYTES_RECEIVED, rv, |
| 2134 scoped_refptr<IOBuffer>(user_read_buf_))); | 2145 scoped_refptr<IOBuffer>(user_read_buf_))); |
| 2135 return rv; | 2146 return rv; |
| 2136 } | 2147 } |
| 2137 PRErrorCode prerr = PR_GetError(); | 2148 PRErrorCode prerr = PR_GetError(); |
| 2138 if (prerr == PR_WOULD_BLOCK_ERROR) | 2149 if (prerr == PR_WOULD_BLOCK_ERROR) |
| 2139 return ERR_IO_PENDING; | 2150 return ERR_IO_PENDING; |
| 2140 | 2151 |
| 2141 rv = HandleNSSError(prerr, false); | 2152 rv = HandleNSSError(prerr, false); |
| 2142 PostOrRunCallback( | 2153 PostOrRunCallback( |
| 2143 FROM_HERE, | 2154 FROM_HERE, |
| 2144 base::Bind(&BoundNetLog::AddEvent, weak_net_log_, | 2155 base::Bind(&AddLogEvent, weak_net_log_, |
| 2145 NetLog::TYPE_SSL_READ_ERROR, | 2156 NetLog::TYPE_SSL_READ_ERROR, |
| 2146 make_scoped_refptr(new SSLErrorParams(rv, prerr)))); | 2157 make_scoped_refptr(new SSLErrorParams(rv, prerr)))); |
| 2147 return rv; | 2158 return rv; |
| 2148 } | 2159 } |
| 2149 | 2160 |
| 2150 int SSLClientSocketNSS::Core::DoPayloadWrite() { | 2161 int SSLClientSocketNSS::Core::DoPayloadWrite() { |
| 2151 DCHECK(OnNSSTaskRunner()); | 2162 DCHECK(OnNSSTaskRunner()); |
| 2152 | 2163 |
| 2153 DCHECK(user_write_buf_); | 2164 DCHECK(user_write_buf_); |
| 2154 | 2165 |
| 2155 int rv = PR_Write(nss_fd_, user_write_buf_->data(), user_write_buf_len_); | 2166 int rv = PR_Write(nss_fd_, user_write_buf_->data(), user_write_buf_len_); |
| 2156 if (rv >= 0) { | 2167 if (rv >= 0) { |
| 2157 PostOrRunCallback( | 2168 PostOrRunCallback( |
| 2158 FROM_HERE, | 2169 FROM_HERE, |
| 2159 base::Bind(&LogByteTransferEvent, weak_net_log_, | 2170 base::Bind(&LogByteTransferEvent, weak_net_log_, |
| 2160 NetLog::TYPE_SSL_SOCKET_BYTES_SENT, rv, | 2171 NetLog::TYPE_SSL_SOCKET_BYTES_SENT, rv, |
| 2161 scoped_refptr<IOBuffer>(user_write_buf_))); | 2172 scoped_refptr<IOBuffer>(user_write_buf_))); |
| 2162 return rv; | 2173 return rv; |
| 2163 } | 2174 } |
| 2164 PRErrorCode prerr = PR_GetError(); | 2175 PRErrorCode prerr = PR_GetError(); |
| 2165 if (prerr == PR_WOULD_BLOCK_ERROR) | 2176 if (prerr == PR_WOULD_BLOCK_ERROR) |
| 2166 return ERR_IO_PENDING; | 2177 return ERR_IO_PENDING; |
| 2167 | 2178 |
| 2168 rv = HandleNSSError(prerr, false); | 2179 rv = HandleNSSError(prerr, false); |
| 2169 PostOrRunCallback( | 2180 PostOrRunCallback( |
| 2170 FROM_HERE, | 2181 FROM_HERE, |
| 2171 base::Bind(&BoundNetLog::AddEvent, weak_net_log_, | 2182 base::Bind(&AddLogEvent, weak_net_log_, |
| 2172 NetLog::TYPE_SSL_WRITE_ERROR, | 2183 NetLog::TYPE_SSL_WRITE_ERROR, |
| 2173 make_scoped_refptr(new SSLErrorParams(rv, prerr)))); | 2184 make_scoped_refptr(new SSLErrorParams(rv, prerr)))); |
| 2174 return rv; | 2185 return rv; |
| 2175 } | 2186 } |
| 2176 | 2187 |
| 2177 // Do as much network I/O as possible between the buffer and the | 2188 // Do as much network I/O as possible between the buffer and the |
| 2178 // transport socket. Return true if some I/O performed, false | 2189 // transport socket. Return true if some I/O performed, false |
| 2179 // otherwise (error or ERR_IO_PENDING). | 2190 // otherwise (error or ERR_IO_PENDING). |
| 2180 bool SSLClientSocketNSS::Core::DoTransportIO() { | 2191 bool SSLClientSocketNSS::Core::DoTransportIO() { |
| 2181 DCHECK(OnNSSTaskRunner()); | 2192 DCHECK(OnNSSTaskRunner()); |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2409 domain_bound_cert_type_ = CLIENT_CERT_INVALID_TYPE; | 2420 domain_bound_cert_type_ = CLIENT_CERT_INVALID_TYPE; |
| 2410 rv = SECFailure; | 2421 rv = SECFailure; |
| 2411 } | 2422 } |
| 2412 } else { | 2423 } else { |
| 2413 rv = SECFailure; | 2424 rv = SECFailure; |
| 2414 } | 2425 } |
| 2415 | 2426 |
| 2416 int cert_count = (rv == SECSuccess) ? 1 : 0; | 2427 int cert_count = (rv == SECSuccess) ? 1 : 0; |
| 2417 PostOrRunCallback( | 2428 PostOrRunCallback( |
| 2418 FROM_HERE, | 2429 FROM_HERE, |
| 2419 base::Bind(&BoundNetLog::AddEvent, weak_net_log_, | 2430 base::Bind(&AddLogEvent, weak_net_log_, |
| 2420 NetLog::TYPE_SSL_CLIENT_CERT_PROVIDED, | 2431 NetLog::TYPE_SSL_CLIENT_CERT_PROVIDED, |
| 2421 make_scoped_refptr( | 2432 make_scoped_refptr( |
| 2422 new NetLogIntegerParameter("cert_count", | 2433 new NetLogIntegerParameter("cert_count", |
| 2423 cert_count)))); | 2434 cert_count)))); |
| 2424 return rv; | 2435 return rv; |
| 2425 } | 2436 } |
| 2426 | 2437 |
| 2427 int SSLClientSocketNSS::Core::ImportDBCertAndKey(CERTCertificate** cert, | 2438 int SSLClientSocketNSS::Core::ImportDBCertAndKey(CERTCertificate** cert, |
| 2428 SECKEYPrivateKey** key) { | 2439 SECKEYPrivateKey** key) { |
| 2429 // Set the certificate. | 2440 // Set the certificate. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2468 return OK; | 2479 return OK; |
| 2469 } | 2480 } |
| 2470 | 2481 |
| 2471 void SSLClientSocketNSS::Core::UpdateServerCert() { | 2482 void SSLClientSocketNSS::Core::UpdateServerCert() { |
| 2472 nss_handshake_state_.server_cert_chain.Reset(nss_fd_); | 2483 nss_handshake_state_.server_cert_chain.Reset(nss_fd_); |
| 2473 nss_handshake_state_.server_cert = X509Certificate::CreateFromDERCertChain( | 2484 nss_handshake_state_.server_cert = X509Certificate::CreateFromDERCertChain( |
| 2474 nss_handshake_state_.server_cert_chain.AsStringPieceVector()); | 2485 nss_handshake_state_.server_cert_chain.AsStringPieceVector()); |
| 2475 if (nss_handshake_state_.server_cert) { | 2486 if (nss_handshake_state_.server_cert) { |
| 2476 PostOrRunCallback( | 2487 PostOrRunCallback( |
| 2477 FROM_HERE, | 2488 FROM_HERE, |
| 2478 base::Bind(&BoundNetLog::AddEvent, weak_net_log_, | 2489 base::Bind(&AddLogEvent, weak_net_log_, |
| 2479 NetLog::TYPE_SSL_CERTIFICATES_RECEIVED, | 2490 NetLog::TYPE_SSL_CERTIFICATES_RECEIVED, |
| 2480 make_scoped_refptr( | 2491 make_scoped_refptr( |
| 2481 new X509CertificateNetLogParam( | 2492 new X509CertificateNetLogParam( |
| 2482 nss_handshake_state_.server_cert)))); | 2493 nss_handshake_state_.server_cert)))); |
| 2483 } | 2494 } |
| 2484 } | 2495 } |
| 2485 | 2496 |
| 2486 void SSLClientSocketNSS::Core::UpdateConnectionStatus() { | 2497 void SSLClientSocketNSS::Core::UpdateConnectionStatus() { |
| 2487 SSLChannelInfo channel_info; | 2498 SSLChannelInfo channel_info; |
| 2488 SECStatus ok = SSL_GetChannelInfo(nss_fd_, | 2499 SECStatus ok = SSL_GetChannelInfo(nss_fd_, |
| (...skipping 1147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3636 EnsureThreadIdAssigned(); | 3647 EnsureThreadIdAssigned(); |
| 3637 base::AutoLock auto_lock(lock_); | 3648 base::AutoLock auto_lock(lock_); |
| 3638 return valid_thread_id_ == base::PlatformThread::CurrentId(); | 3649 return valid_thread_id_ == base::PlatformThread::CurrentId(); |
| 3639 } | 3650 } |
| 3640 | 3651 |
| 3641 ServerBoundCertService* SSLClientSocketNSS::GetServerBoundCertService() const { | 3652 ServerBoundCertService* SSLClientSocketNSS::GetServerBoundCertService() const { |
| 3642 return server_bound_cert_service_; | 3653 return server_bound_cert_service_; |
| 3643 } | 3654 } |
| 3644 | 3655 |
| 3645 } // namespace net | 3656 } // namespace net |
| OLD | NEW |