| 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 1705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1716 | 1716 |
| 1717 if (!start_cert_verification_time_.is_null()) { | 1717 if (!start_cert_verification_time_.is_null()) { |
| 1718 base::TimeDelta verify_time = | 1718 base::TimeDelta verify_time = |
| 1719 base::TimeTicks::Now() - start_cert_verification_time_; | 1719 base::TimeTicks::Now() - start_cert_verification_time_; |
| 1720 if (result == OK) | 1720 if (result == OK) |
| 1721 UMA_HISTOGRAM_TIMES("Net.SSLCertVerificationTime", verify_time); | 1721 UMA_HISTOGRAM_TIMES("Net.SSLCertVerificationTime", verify_time); |
| 1722 else | 1722 else |
| 1723 UMA_HISTOGRAM_TIMES("Net.SSLCertVerificationTimeError", verify_time); | 1723 UMA_HISTOGRAM_TIMES("Net.SSLCertVerificationTimeError", verify_time); |
| 1724 } | 1724 } |
| 1725 | 1725 |
| 1726 PeerCertificateChain chain(nss_fd_); | |
| 1727 for (unsigned i = 1; i < chain.size(); i++) { | |
| 1728 if (strcmp(chain[i]->subjectName, "CN=meta") != 0) | |
| 1729 continue; | |
| 1730 | |
| 1731 base::StringPiece leaf_der( | |
| 1732 reinterpret_cast<char*>(server_cert_nss_->derCert.data), | |
| 1733 server_cert_nss_->derCert.len); | |
| 1734 base::StringPiece leaf_spki; | |
| 1735 if (!asn1::ExtractSPKIFromDERCert(leaf_der, &leaf_spki)) | |
| 1736 break; | |
| 1737 | |
| 1738 static SECOidTag side_data_tag; | |
| 1739 static bool side_data_tag_valid; | |
| 1740 if (!side_data_tag_valid) { | |
| 1741 // It's harmless if multiple threads enter this block concurrently. | |
| 1742 static const uint8 kSideDataOID[] = | |
| 1743 // 1.3.6.1.4.1.11129.2.1.4 | |
| 1744 // (iso.org.dod.internet.private.enterprises.google.googleSecurity. | |
| 1745 // certificateExtensions.sideData) | |
| 1746 {0x2b, 0x06, 0x01, 0x04, 0x01, 0xd6, 0x79, 0x02, 0x01, 0x05}; | |
| 1747 SECOidData oid_data; | |
| 1748 memset(&oid_data, 0, sizeof(oid_data)); | |
| 1749 oid_data.oid.data = const_cast<uint8*>(kSideDataOID); | |
| 1750 oid_data.oid.len = sizeof(kSideDataOID); | |
| 1751 oid_data.desc = "Certificate side data"; | |
| 1752 oid_data.supportedExtension = SUPPORTED_CERT_EXTENSION; | |
| 1753 side_data_tag = SECOID_AddEntry(&oid_data); | |
| 1754 DCHECK_NE(SEC_OID_UNKNOWN, side_data_tag); | |
| 1755 side_data_tag_valid = true; | |
| 1756 } | |
| 1757 | |
| 1758 SECItem side_data_item; | |
| 1759 SECStatus rv = CERT_FindCertExtension(chain[i], | |
| 1760 side_data_tag, &side_data_item); | |
| 1761 if (rv != SECSuccess) | |
| 1762 continue; | |
| 1763 | |
| 1764 base::StringPiece side_data( | |
| 1765 reinterpret_cast<char*>(side_data_item.data), | |
| 1766 side_data_item.len); | |
| 1767 | |
| 1768 if (!TransportSecurityState::ParseSidePin( | |
| 1769 leaf_spki, side_data, &side_pinned_public_keys_)) { | |
| 1770 LOG(WARNING) << "Side pinning data failed to parse: " | |
| 1771 << host_and_port_.host(); | |
| 1772 } | |
| 1773 break; | |
| 1774 } | |
| 1775 | |
| 1776 // We used to remember the intermediate CA certs in the NSS database | 1726 // We used to remember the intermediate CA certs in the NSS database |
| 1777 // persistently. However, NSS opens a connection to the SQLite database | 1727 // persistently. However, NSS opens a connection to the SQLite database |
| 1778 // during NSS initialization and doesn't close the connection until NSS | 1728 // during NSS initialization and doesn't close the connection until NSS |
| 1779 // shuts down. If the file system where the database resides is gone, | 1729 // shuts down. If the file system where the database resides is gone, |
| 1780 // the database connection goes bad. What's worse, the connection won't | 1730 // the database connection goes bad. What's worse, the connection won't |
| 1781 // recover when the file system comes back. Until this NSS or SQLite bug | 1731 // recover when the file system comes back. Until this NSS or SQLite bug |
| 1782 // is fixed, we need to avoid using the NSS database for non-essential | 1732 // is fixed, we need to avoid using the NSS database for non-essential |
| 1783 // purposes. See https://bugzilla.mozilla.org/show_bug.cgi?id=508081 and | 1733 // purposes. See https://bugzilla.mozilla.org/show_bug.cgi?id=508081 and |
| 1784 // http://crbug.com/15630 for more info. | 1734 // http://crbug.com/15630 for more info. |
| 1785 | 1735 |
| (...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2656 EnsureThreadIdAssigned(); | 2606 EnsureThreadIdAssigned(); |
| 2657 base::AutoLock auto_lock(lock_); | 2607 base::AutoLock auto_lock(lock_); |
| 2658 return valid_thread_id_ == base::PlatformThread::CurrentId(); | 2608 return valid_thread_id_ == base::PlatformThread::CurrentId(); |
| 2659 } | 2609 } |
| 2660 | 2610 |
| 2661 ServerBoundCertService* SSLClientSocketNSS::GetServerBoundCertService() const { | 2611 ServerBoundCertService* SSLClientSocketNSS::GetServerBoundCertService() const { |
| 2662 return server_bound_cert_service_; | 2612 return server_bound_cert_service_; |
| 2663 } | 2613 } |
| 2664 | 2614 |
| 2665 } // namespace net | 2615 } // namespace net |
| OLD | NEW |