Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(938)

Side by Side Diff: net/socket/ssl_client_socket_nss.cc

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

Powered by Google App Engine
This is Rietveld 408576698