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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 #include "net/base/address_list.h" | 87 #include "net/base/address_list.h" |
88 #include "net/base/connection_type_histograms.h" | 88 #include "net/base/connection_type_histograms.h" |
89 #include "net/base/dns_util.h" | 89 #include "net/base/dns_util.h" |
90 #include "net/base/io_buffer.h" | 90 #include "net/base/io_buffer.h" |
91 #include "net/base/net_errors.h" | 91 #include "net/base/net_errors.h" |
92 #include "net/base/net_log.h" | 92 #include "net/base/net_log.h" |
93 #include "net/cert/asn1_util.h" | 93 #include "net/cert/asn1_util.h" |
94 #include "net/cert/cert_status_flags.h" | 94 #include "net/cert/cert_status_flags.h" |
95 #include "net/cert/cert_verifier.h" | 95 #include "net/cert/cert_verifier.h" |
96 #include "net/cert/ct_verifier.h" | 96 #include "net/cert/ct_verifier.h" |
| 97 #include "net/cert/ct_verify_result.h" |
97 #include "net/cert/scoped_nss_types.h" | 98 #include "net/cert/scoped_nss_types.h" |
| 99 #include "net/cert/sct_status_flags.h" |
98 #include "net/cert/single_request_cert_verifier.h" | 100 #include "net/cert/single_request_cert_verifier.h" |
99 #include "net/cert/x509_certificate_net_log_param.h" | 101 #include "net/cert/x509_certificate_net_log_param.h" |
100 #include "net/cert/x509_util.h" | 102 #include "net/cert/x509_util.h" |
101 #include "net/http/transport_security_state.h" | 103 #include "net/http/transport_security_state.h" |
102 #include "net/ocsp/nss_ocsp.h" | 104 #include "net/ocsp/nss_ocsp.h" |
103 #include "net/socket/client_socket_handle.h" | 105 #include "net/socket/client_socket_handle.h" |
104 #include "net/socket/nss_ssl_util.h" | 106 #include "net/socket/nss_ssl_util.h" |
105 #include "net/socket/ssl_error_params.h" | 107 #include "net/socket/ssl_error_params.h" |
106 #include "net/ssl/ssl_cert_request_info.h" | 108 #include "net/ssl/ssl_cert_request_info.h" |
107 #include "net/ssl/ssl_connection_status_flags.h" | 109 #include "net/ssl/ssl_connection_status_flags.h" |
(...skipping 2688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2796 bool SSLClientSocketNSS::GetSSLInfo(SSLInfo* ssl_info) { | 2798 bool SSLClientSocketNSS::GetSSLInfo(SSLInfo* ssl_info) { |
2797 EnterFunction(""); | 2799 EnterFunction(""); |
2798 ssl_info->Reset(); | 2800 ssl_info->Reset(); |
2799 if (core_->state().server_cert_chain.empty() || | 2801 if (core_->state().server_cert_chain.empty() || |
2800 !core_->state().server_cert_chain[0]) { | 2802 !core_->state().server_cert_chain[0]) { |
2801 return false; | 2803 return false; |
2802 } | 2804 } |
2803 | 2805 |
2804 ssl_info->cert_status = server_cert_verify_result_.cert_status; | 2806 ssl_info->cert_status = server_cert_verify_result_.cert_status; |
2805 ssl_info->cert = server_cert_verify_result_.verified_cert; | 2807 ssl_info->cert = server_cert_verify_result_.verified_cert; |
| 2808 |
| 2809 AddSCTInfoToSSLInfo(ssl_info); |
| 2810 |
2806 ssl_info->connection_status = | 2811 ssl_info->connection_status = |
2807 core_->state().ssl_connection_status; | 2812 core_->state().ssl_connection_status; |
2808 ssl_info->public_key_hashes = server_cert_verify_result_.public_key_hashes; | 2813 ssl_info->public_key_hashes = server_cert_verify_result_.public_key_hashes; |
2809 for (HashValueVector::const_iterator i = side_pinned_public_keys_.begin(); | 2814 for (HashValueVector::const_iterator i = side_pinned_public_keys_.begin(); |
2810 i != side_pinned_public_keys_.end(); ++i) { | 2815 i != side_pinned_public_keys_.end(); ++i) { |
2811 ssl_info->public_key_hashes.push_back(*i); | 2816 ssl_info->public_key_hashes.push_back(*i); |
2812 } | 2817 } |
2813 ssl_info->is_issued_by_known_root = | 2818 ssl_info->is_issued_by_known_root = |
2814 server_cert_verify_result_.is_issued_by_known_root; | 2819 server_cert_verify_result_.is_issued_by_known_root; |
2815 ssl_info->client_cert_sent = | 2820 ssl_info->client_cert_sent = |
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3489 // external communication | 3494 // external communication |
3490 return cert_transparency_verifier_->Verify( | 3495 return cert_transparency_verifier_->Verify( |
3491 server_cert_verify_result_.verified_cert, | 3496 server_cert_verify_result_.verified_cert, |
3492 std::string(), // SCT list from OCSP stapling response | 3497 std::string(), // SCT list from OCSP stapling response |
3493 std::string(), // SCT list from TLS handshake | 3498 std::string(), // SCT list from TLS handshake |
3494 &ct_verify_result_); | 3499 &ct_verify_result_); |
3495 } | 3500 } |
3496 | 3501 |
3497 int SSLClientSocketNSS::DoVerifyCTComplete(int result) { | 3502 int SSLClientSocketNSS::DoVerifyCTComplete(int result) { |
3498 VLOG(1) << "CT Verification complete: result " << result | 3503 VLOG(1) << "CT Verification complete: result " << result |
3499 << " Unverified scts: " << ct_verify_result_.unverified_scts.size() | 3504 << " Invalid scts: " << ct_verify_result_.invalid_scts.size() |
3500 << " Verified scts: " << ct_verify_result_.verified_scts.size() | 3505 << " Verified scts: " << ct_verify_result_.verified_scts.size() |
3501 << " scts from unknown logs: " | 3506 << " scts from unknown logs: " |
3502 << ct_verify_result_.unknown_logs_scts.size(); | 3507 << ct_verify_result_.unknown_logs_scts.size(); |
3503 | 3508 |
3504 if (!ct_verify_result_.unverified_scts.empty() || | 3509 if (!ct_verify_result_.invalid_scts.empty() || |
3505 !ct_verify_result_.unknown_logs_scts.empty() || | 3510 !ct_verify_result_.unknown_logs_scts.empty() || |
3506 !ct_verify_result_.verified_scts.empty()) { | 3511 !ct_verify_result_.verified_scts.empty()) { |
3507 | 3512 |
3508 // Saving CT state in cert_status bits, in addition to the SCTs themselves | 3513 // Saving CT state in cert_status bits, in addition to the SCTs themselves |
3509 // (which will be threaded into the SSLInfo, as well as into the HTTP | 3514 // (which will be threaded into the SSLInfo, as well as into the HTTP |
3510 // cache). | 3515 // cache). |
3511 // This persists the CT status and simplifies UI code for figuring out | 3516 // This persists the CT status and simplifies UI code for figuring out |
3512 // the right CT info to display. | 3517 // the right CT info to display. |
3513 bool has_verified_scts = !ct_verify_result_.verified_scts.empty() && | 3518 bool has_verified_scts = !ct_verify_result_.verified_scts.empty() && |
3514 result == OK; | 3519 result == OK; |
3515 if (has_verified_scts || !ct_verify_result_.unverified_scts.empty()) { | 3520 if (has_verified_scts || !ct_verify_result_.invalid_scts.empty()) { |
3516 // Found SCTs from a known log. | 3521 // Found SCTs from a known log. |
3517 server_cert_verify_result_.cert_status = | 3522 server_cert_verify_result_.cert_status = |
3518 CERT_STATUS_HAS_SCT_FROM_KNOWN_LOG; | 3523 CERT_STATUS_HAS_SCT_FROM_KNOWN_LOG; |
3519 if (has_verified_scts) { | 3524 if (has_verified_scts) { |
3520 server_cert_verify_result_.cert_status |= CERT_STATUS_HAS_GOOD_SCT; | 3525 server_cert_verify_result_.cert_status |= CERT_STATUS_HAS_GOOD_SCT; |
3521 } | 3526 } |
3522 } else { | 3527 } else { |
3523 DCHECK(!ct_verify_result_.unknown_logs_scts.empty()); | 3528 DCHECK(!ct_verify_result_.unknown_logs_scts.empty()); |
3524 // When this bit is set but CERT_STATUS_HAS_SCT_FROM_KNOWN_LOG isn't | 3529 // When this bit is set but CERT_STATUS_HAS_SCT_FROM_KNOWN_LOG isn't |
3525 // that implies SCTs from unknown logs. | 3530 // that implies SCTs from unknown logs. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3562 return; | 3567 return; |
3563 valid_thread_id_ = base::PlatformThread::CurrentId(); | 3568 valid_thread_id_ = base::PlatformThread::CurrentId(); |
3564 } | 3569 } |
3565 | 3570 |
3566 bool SSLClientSocketNSS::CalledOnValidThread() const { | 3571 bool SSLClientSocketNSS::CalledOnValidThread() const { |
3567 EnsureThreadIdAssigned(); | 3572 EnsureThreadIdAssigned(); |
3568 base::AutoLock auto_lock(lock_); | 3573 base::AutoLock auto_lock(lock_); |
3569 return valid_thread_id_ == base::PlatformThread::CurrentId(); | 3574 return valid_thread_id_ == base::PlatformThread::CurrentId(); |
3570 } | 3575 } |
3571 | 3576 |
| 3577 void SSLClientSocketNSS::AddSCTInfoToSSLInfo(SSLInfo* ssl_info) const { |
| 3578 for (ct::SCTList::const_iterator iter = |
| 3579 ct_verify_result_.verified_scts.begin(); |
| 3580 iter != ct_verify_result_.verified_scts.end(); ++iter) { |
| 3581 ssl_info->signed_certificate_timestamps.push_back( |
| 3582 SignedCertificateTimestampAndStatus(*iter, ct::SCT_STATUS_OK)); |
| 3583 } |
| 3584 for (ct::SCTList::const_iterator iter = |
| 3585 ct_verify_result_.invalid_scts.begin(); |
| 3586 iter != ct_verify_result_.invalid_scts.end(); ++iter) { |
| 3587 ssl_info->signed_certificate_timestamps.push_back( |
| 3588 SignedCertificateTimestampAndStatus(*iter, ct::SCT_STATUS_INVALID)); |
| 3589 } |
| 3590 for (ct::SCTList::const_iterator iter = |
| 3591 ct_verify_result_.unknown_logs_scts.begin(); |
| 3592 iter != ct_verify_result_.unknown_logs_scts.end(); ++iter) { |
| 3593 ssl_info->signed_certificate_timestamps.push_back( |
| 3594 SignedCertificateTimestampAndStatus(*iter, |
| 3595 ct::SCT_STATUS_LOG_UNKNOWN)); |
| 3596 } |
| 3597 } |
| 3598 |
3572 ServerBoundCertService* SSLClientSocketNSS::GetServerBoundCertService() const { | 3599 ServerBoundCertService* SSLClientSocketNSS::GetServerBoundCertService() const { |
3573 return server_bound_cert_service_; | 3600 return server_bound_cert_service_; |
3574 } | 3601 } |
3575 | 3602 |
3576 } // namespace net | 3603 } // namespace net |
OLD | NEW |