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. |
| 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 2112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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) { |
2518 PostOrRunCallback( | 2532 PostOrRunCallback( |
2519 FROM_HERE, | 2533 FROM_HERE, |
2520 base::Bind(&AddLogEvent, weak_net_log_, | 2534 base::Bind(&AddLogEventWithCallback, weak_net_log_, |
2521 NetLog::TYPE_SSL_CERTIFICATES_RECEIVED, | 2535 NetLog::TYPE_SSL_CERTIFICATES_RECEIVED, |
2522 make_scoped_refptr( | 2536 base::Bind(&NetLogX509CertificateNetLogCallback, |
2523 new X509CertificateNetLogParam( | 2537 nss_handshake_state_.server_cert))); |
2524 nss_handshake_state_.server_cert)))); | |
2525 } | 2538 } |
2526 } | 2539 } |
2527 | 2540 |
2528 void SSLClientSocketNSS::Core::UpdateConnectionStatus() { | 2541 void SSLClientSocketNSS::Core::UpdateConnectionStatus() { |
2529 SSLChannelInfo channel_info; | 2542 SSLChannelInfo channel_info; |
2530 SECStatus ok = SSL_GetChannelInfo(nss_fd_, | 2543 SECStatus ok = SSL_GetChannelInfo(nss_fd_, |
2531 &channel_info, sizeof(channel_info)); | 2544 &channel_info, sizeof(channel_info)); |
2532 if (ok == SECSuccess && | 2545 if (ok == SECSuccess && |
2533 channel_info.length == sizeof(channel_info) && | 2546 channel_info.length == sizeof(channel_info) && |
2534 channel_info.cipherSuite) { | 2547 channel_info.cipherSuite) { |
(...skipping 1146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3681 EnsureThreadIdAssigned(); | 3694 EnsureThreadIdAssigned(); |
3682 base::AutoLock auto_lock(lock_); | 3695 base::AutoLock auto_lock(lock_); |
3683 return valid_thread_id_ == base::PlatformThread::CurrentId(); | 3696 return valid_thread_id_ == base::PlatformThread::CurrentId(); |
3684 } | 3697 } |
3685 | 3698 |
3686 ServerBoundCertService* SSLClientSocketNSS::GetServerBoundCertService() const { | 3699 ServerBoundCertService* SSLClientSocketNSS::GetServerBoundCertService() const { |
3687 return server_bound_cert_service_; | 3700 return server_bound_cert_service_; |
3688 } | 3701 } |
3689 | 3702 |
3690 } // namespace net | 3703 } // namespace net |
OLD | NEW |