Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "net/socket/ssl_host_info.h" | 5 #include "net/socket/ssl_host_info.h" |
| 6 | 6 |
| 7 #include "base/metrics/histogram.h" | |
| 7 #include "base/string_piece.h" | 8 #include "base/string_piece.h" |
| 8 #include "net/base/cert_verifier.h" | 9 #include "net/base/cert_verifier.h" |
| 9 #include "net/base/ssl_config_service.h" | 10 #include "net/base/ssl_config_service.h" |
| 10 #include "net/base/x509_certificate.h" | 11 #include "net/base/x509_certificate.h" |
| 11 #include "net/socket/ssl_client_socket.h" | 12 #include "net/socket/ssl_client_socket.h" |
| 12 #include "net/socket/ssl_host_info.pb.h" | 13 #include "net/socket/ssl_host_info.pb.h" |
| 13 | 14 |
| 14 namespace net { | 15 namespace net { |
| 15 | 16 |
| 16 SSLHostInfo::State::State() | 17 SSLHostInfo::State::State() |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 103 der_certs[i] = state->certs[i]; | 104 der_certs[i] = state->certs[i]; |
| 104 cert_ = X509Certificate::CreateFromDERCertChain(der_certs); | 105 cert_ = X509Certificate::CreateFromDERCertChain(der_certs); |
| 105 if (cert_.get()) { | 106 if (cert_.get()) { |
| 106 int flags = 0; | 107 int flags = 0; |
| 107 if (verify_ev_cert_) | 108 if (verify_ev_cert_) |
| 108 flags |= X509Certificate::VERIFY_EV_CERT; | 109 flags |= X509Certificate::VERIFY_EV_CERT; |
| 109 if (rev_checking_enabled_) | 110 if (rev_checking_enabled_) |
| 110 flags |= X509Certificate::VERIFY_REV_CHECKING_ENABLED; | 111 flags |= X509Certificate::VERIFY_REV_CHECKING_ENABLED; |
| 111 verifier_.reset(new CertVerifier); | 112 verifier_.reset(new CertVerifier); |
| 112 VLOG(1) << "Kicking off verification for " << hostname_; | 113 VLOG(1) << "Kicking off verification for " << hostname_; |
| 114 verification_start_time_ = base::TimeTicks::Now(); | |
| 113 if (verifier_->Verify(cert_.get(), hostname_, flags, | 115 if (verifier_->Verify(cert_.get(), hostname_, flags, |
| 114 &cert_verify_result_, callback_) == OK) { | 116 &cert_verify_result_, callback_) == OK) { |
| 115 VerifyCallback(OK); | 117 VerifyCallback(OK); |
| 116 } | 118 } |
| 117 } else { | 119 } else { |
| 118 cert_parsing_failed_ = true; | 120 cert_parsing_failed_ = true; |
| 119 DCHECK(!cert_verification_callback_); | 121 DCHECK(!cert_verification_callback_); |
| 120 } | 122 } |
| 121 } | 123 } |
| 122 | 124 |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 148 int SSLHostInfo::WaitForCertVerification(CompletionCallback* callback) { | 150 int SSLHostInfo::WaitForCertVerification(CompletionCallback* callback) { |
| 149 if (cert_verification_complete_) | 151 if (cert_verification_complete_) |
| 150 return cert_verification_result_; | 152 return cert_verification_result_; |
| 151 DCHECK(!cert_parsing_failed_); | 153 DCHECK(!cert_parsing_failed_); |
| 152 DCHECK(!cert_verification_callback_); | 154 DCHECK(!cert_verification_callback_); |
| 153 DCHECK(!state_.certs.empty()); | 155 DCHECK(!state_.certs.empty()); |
| 154 cert_verification_callback_ = callback; | 156 cert_verification_callback_ = callback; |
| 155 return ERR_IO_PENDING; | 157 return ERR_IO_PENDING; |
| 156 } | 158 } |
| 157 | 159 |
| 158 void SSLHostInfo::VerifyCallback(int rv) { | 160 void SSLHostInfo::VerifyCallback(int rv) { |
|
Mike Belshe
2010/11/03 19:55:11
nit: add DCHECK(!verification_start_time().is_nul
| |
| 161 base::TimeTicks now = base::TimeTicks::Now(); | |
| 162 const base::TimeDelta duration = now - verification_start_time(); | |
| 163 UMA_HISTOGRAM_TIMES("Net.SSLHostInfoVerificationTimeMs", duration); | |
| 164 VLOG(1) << "Verification took " << duration.InMilliseconds() << "ms"; | |
| 159 cert_verification_complete_ = true; | 165 cert_verification_complete_ = true; |
| 160 cert_verification_result_ = rv; | 166 cert_verification_result_ = rv; |
| 161 if (cert_verification_callback_) { | 167 if (cert_verification_callback_) { |
| 162 CompletionCallback* callback = cert_verification_callback_; | 168 CompletionCallback* callback = cert_verification_callback_; |
| 163 cert_verification_callback_ = NULL; | 169 cert_verification_callback_ = NULL; |
| 164 callback->Run(rv); | 170 callback->Run(rv); |
| 165 } | 171 } |
| 166 } | 172 } |
| 167 | 173 |
| 168 SSLHostInfoFactory::~SSLHostInfoFactory() {} | 174 SSLHostInfoFactory::~SSLHostInfoFactory() {} |
| 169 | 175 |
| 170 } // namespace net | 176 } // namespace net |
| OLD | NEW |