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 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 | 385 // Helper function to make it possible to log events from within the |
386 // SSLClientSocketNSS::Core. Can't use Bind with BoundNetLog::AddEntry directly | 386 // SSLClientSocketNSS::Core. Can't use Bind with BoundNetLog::AddEntry directly |
387 // on Windows because it is overloaded. | 387 // on Windows because it is overloaded. |
388 // TODO(mmenke): Other than shutdown, NetLog is threadsafe. Figure out if this | |
389 // is needed. | |
Ryan Sleevi
2012/06/12 17:14:38
This was needed because existing consumers of NetL
mmenke
2012/06/12 17:37:24
Thanks for the explanation.
| |
390 void AddLogEventWithCallback(BoundNetLog* net_log, | |
391 NetLog::EventType event_type, | |
392 const NetLog::ParametersCallback& callback) { | |
393 if (!net_log) | |
394 return; | |
395 net_log->AddEvent(event_type, callback); | |
396 } | |
397 | |
398 // Helper functions to make it possible to log events from within the | |
399 // SSLClientSocketNSS::Core. Can't use Bind with BoundNetLog::AddEntry directly | |
400 // on Windows because it is overloaded. | |
401 // TODO(mmenke): This function is deprecated, delete it. | |
388 void AddLogEvent(BoundNetLog* net_log, | 402 void AddLogEvent(BoundNetLog* net_log, |
389 NetLog::EventType event_type, | 403 NetLog::EventType event_type, |
390 const scoped_refptr<NetLog::EventParameters>& event_params) { | 404 const scoped_refptr<NetLog::EventParameters>& event_params) { |
391 if (!net_log) | 405 if (!net_log) |
392 return; | 406 return; |
393 net_log->AddEvent(event_type, event_params); | 407 net_log->AddEvent(event_type, event_params); |
394 } | 408 } |
395 | 409 |
396 // Helper function to make it easier to call BoundNetLog::AddByteTransferEvent | 410 // Helper function to make it easier to call BoundNetLog::AddByteTransferEvent |
397 // from within the SSLClientSocketNSS::Core. | 411 // from within the SSLClientSocketNSS::Core. |
(...skipping 2110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2508 } | 2522 } |
2509 | 2523 |
2510 return OK; | 2524 return OK; |
2511 } | 2525 } |
2512 | 2526 |
2513 void SSLClientSocketNSS::Core::UpdateServerCert() { | 2527 void SSLClientSocketNSS::Core::UpdateServerCert() { |
2514 nss_handshake_state_.server_cert_chain.Reset(nss_fd_); | 2528 nss_handshake_state_.server_cert_chain.Reset(nss_fd_); |
2515 nss_handshake_state_.server_cert = X509Certificate::CreateFromDERCertChain( | 2529 nss_handshake_state_.server_cert = X509Certificate::CreateFromDERCertChain( |
2516 nss_handshake_state_.server_cert_chain.AsStringPieceVector()); | 2530 nss_handshake_state_.server_cert_chain.AsStringPieceVector()); |
2517 if (nss_handshake_state_.server_cert) { | 2531 if (nss_handshake_state_.server_cert) { |
2532 NetLog::ParametersCallback net_log_callback = | |
2533 base::Bind(&NetLogX509CertificateCallback, | |
2534 base::Unretained(nss_handshake_state_.server_cert.get())); | |
Ryan Sleevi
2012/06/12 17:14:38
I believe this is wrong.
nss_handshake_state_ sho
eroman
2012/06/12 17:30:11
Thanks Ryan! I hadn't read this carefully, you are
mmenke
2012/06/12 17:37:24
Thanks for catching this, a clear bug.
Options:
eroman
2012/06/12 17:47:52
It doesn't look like load_timing_observer actually
| |
2518 PostOrRunCallback( | 2535 PostOrRunCallback( |
2519 FROM_HERE, | 2536 FROM_HERE, |
2520 base::Bind(&AddLogEvent, weak_net_log_, | 2537 base::Bind(&AddLogEventWithCallback, weak_net_log_, |
2521 NetLog::TYPE_SSL_CERTIFICATES_RECEIVED, | 2538 NetLog::TYPE_SSL_CERTIFICATES_RECEIVED, |
2522 make_scoped_refptr( | 2539 net_log_callback)); |
2523 new X509CertificateNetLogParam( | |
2524 nss_handshake_state_.server_cert)))); | |
2525 } | 2540 } |
2526 } | 2541 } |
2527 | 2542 |
2528 void SSLClientSocketNSS::Core::UpdateConnectionStatus() { | 2543 void SSLClientSocketNSS::Core::UpdateConnectionStatus() { |
2529 SSLChannelInfo channel_info; | 2544 SSLChannelInfo channel_info; |
2530 SECStatus ok = SSL_GetChannelInfo(nss_fd_, | 2545 SECStatus ok = SSL_GetChannelInfo(nss_fd_, |
2531 &channel_info, sizeof(channel_info)); | 2546 &channel_info, sizeof(channel_info)); |
2532 if (ok == SECSuccess && | 2547 if (ok == SECSuccess && |
2533 channel_info.length == sizeof(channel_info) && | 2548 channel_info.length == sizeof(channel_info) && |
2534 channel_info.cipherSuite) { | 2549 channel_info.cipherSuite) { |
(...skipping 1146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3681 EnsureThreadIdAssigned(); | 3696 EnsureThreadIdAssigned(); |
3682 base::AutoLock auto_lock(lock_); | 3697 base::AutoLock auto_lock(lock_); |
3683 return valid_thread_id_ == base::PlatformThread::CurrentId(); | 3698 return valid_thread_id_ == base::PlatformThread::CurrentId(); |
3684 } | 3699 } |
3685 | 3700 |
3686 ServerBoundCertService* SSLClientSocketNSS::GetServerBoundCertService() const { | 3701 ServerBoundCertService* SSLClientSocketNSS::GetServerBoundCertService() const { |
3687 return server_bound_cert_service_; | 3702 return server_bound_cert_service_; |
3688 } | 3703 } |
3689 | 3704 |
3690 } // namespace net | 3705 } // namespace net |
OLD | NEW |