[email protected] | 2662ed56 | 2013-07-03 10:27:46 | [diff] [blame] | 1 | // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
rch | 675757b | 2016-07-29 16:40:11 | [diff] [blame] | 5 | #include "net/quic/chromium/crypto/proof_verifier_chromium.h" |
[email protected] | 2662ed56 | 2013-07-03 10:27:46 | [diff] [blame] | 6 | |
dcheng | c7eeda42 | 2015-12-26 03:56:48 | [diff] [blame] | 7 | #include <utility> |
| 8 | |
[email protected] | 2662ed56 | 2013-07-03 10:27:46 | [diff] [blame] | 9 | #include "base/bind.h" |
| 10 | #include "base/bind_helpers.h" |
| 11 | #include "base/callback_helpers.h" |
[email protected] | 2662ed56 | 2013-07-03 10:27:46 | [diff] [blame] | 12 | #include "base/logging.h" |
asvitkine | c3c9372 | 2015-06-17 14:48:37 | [diff] [blame] | 13 | #include "base/metrics/histogram_macros.h" |
[email protected] | 5c78ce6 | 2014-03-13 19:48:01 | [diff] [blame] | 14 | #include "base/stl_util.h" |
[email protected] | 2662ed56 | 2013-07-03 10:27:46 | [diff] [blame] | 15 | #include "base/strings/stringprintf.h" |
| 16 | #include "crypto/signature_verifier.h" |
estark | 1a66df7 | 2015-07-28 15:24:00 | [diff] [blame] | 17 | #include "net/base/host_port_pair.h" |
[email protected] | 2662ed56 | 2013-07-03 10:27:46 | [diff] [blame] | 18 | #include "net/base/net_errors.h" |
[email protected] | 2662ed56 | 2013-07-03 10:27:46 | [diff] [blame] | 19 | #include "net/cert/asn1_util.h" |
| 20 | #include "net/cert/cert_status_flags.h" |
| 21 | #include "net/cert/cert_verifier.h" |
estark | 6f9b3d8 | 2016-01-12 21:37:05 | [diff] [blame] | 22 | #include "net/cert/ct_policy_enforcer.h" |
estark | 723b5eeb | 2016-02-18 21:01:12 | [diff] [blame] | 23 | #include "net/cert/ct_policy_status.h" |
rtenneti | 052774e | 2015-11-24 21:00:12 | [diff] [blame] | 24 | #include "net/cert/ct_verifier.h" |
[email protected] | 2662ed56 | 2013-07-03 10:27:46 | [diff] [blame] | 25 | #include "net/cert/x509_util.h" |
[email protected] | 080b7793 | 2014-08-04 01:22:46 | [diff] [blame] | 26 | #include "net/http/transport_security_state.h" |
rch | d4db7c15 | 2016-07-29 21:58:12 | [diff] [blame] | 27 | #include "net/quic/core/crypto/crypto_protocol.h" |
[email protected] | 2662ed56 | 2013-07-03 10:27:46 | [diff] [blame] | 28 | #include "net/ssl/ssl_config_service.h" |
| 29 | |
| 30 | using base::StringPiece; |
| 31 | using base::StringPrintf; |
| 32 | using std::string; |
| 33 | using std::vector; |
| 34 | |
| 35 | namespace net { |
| 36 | |
dadrian | df302c4 | 2016-06-10 18:48:59 | [diff] [blame] | 37 | ProofVerifyDetailsChromium::ProofVerifyDetailsChromium() |
| 38 | : pkp_bypassed(false) {} |
| 39 | |
| 40 | ProofVerifyDetailsChromium::~ProofVerifyDetailsChromium() {} |
| 41 | |
| 42 | ProofVerifyDetailsChromium::ProofVerifyDetailsChromium( |
| 43 | const ProofVerifyDetailsChromium&) = default; |
| 44 | |
[email protected] | 92bc621d | 2014-07-29 21:42:13 | [diff] [blame] | 45 | ProofVerifyDetails* ProofVerifyDetailsChromium::Clone() const { |
| 46 | ProofVerifyDetailsChromium* other = new ProofVerifyDetailsChromium; |
| 47 | other->cert_verify_result = cert_verify_result; |
rtenneti | 052774e | 2015-11-24 21:00:12 | [diff] [blame] | 48 | other->ct_verify_result = ct_verify_result; |
[email protected] | 92bc621d | 2014-07-29 21:42:13 | [diff] [blame] | 49 | return other; |
| 50 | } |
| 51 | |
[email protected] | 5c78ce6 | 2014-03-13 19:48:01 | [diff] [blame] | 52 | // A Job handles the verification of a single proof. It is owned by the |
| 53 | // ProofVerifier. If the verification can not complete synchronously, it |
| 54 | // will notify the ProofVerifier upon completion. |
| 55 | class ProofVerifierChromium::Job { |
| 56 | public: |
| 57 | Job(ProofVerifierChromium* proof_verifier, |
| 58 | CertVerifier* cert_verifier, |
estark | 6f9b3d8 | 2016-01-12 21:37:05 | [diff] [blame] | 59 | CTPolicyEnforcer* ct_policy_enforcer, |
[email protected] | 080b7793 | 2014-08-04 01:22:46 | [diff] [blame] | 60 | TransportSecurityState* transport_security_state, |
rtenneti | 052774e | 2015-11-24 21:00:12 | [diff] [blame] | 61 | CTVerifier* cert_transparency_verifier, |
rtenneti | a75df62 | 2015-06-21 23:59:50 | [diff] [blame] | 62 | int cert_verify_flags, |
[email protected] | 5c78ce6 | 2014-03-13 19:48:01 | [diff] [blame] | 63 | const BoundNetLog& net_log); |
rtenneti | dd4f1bd7 | 2015-12-23 19:17:50 | [diff] [blame] | 64 | ~Job(); |
[email protected] | 5c78ce6 | 2014-03-13 19:48:01 | [diff] [blame] | 65 | |
[email protected] | 05bfc260f | 2014-06-07 06:31:25 | [diff] [blame] | 66 | // Starts the proof verification. If |QUIC_PENDING| is returned, then |
| 67 | // |callback| will be invoked asynchronously when the verification completes. |
danakj | ad1777e | 2016-04-16 00:56:42 | [diff] [blame] | 68 | QuicAsyncStatus VerifyProof( |
| 69 | const std::string& hostname, |
| 70 | const uint16_t port, |
| 71 | const std::string& server_config, |
| 72 | QuicVersion quic_version, |
| 73 | base::StringPiece chlo_hash, |
| 74 | const std::vector<std::string>& certs, |
| 75 | const std::string& cert_sct, |
| 76 | const std::string& signature, |
| 77 | std::string* error_details, |
| 78 | std::unique_ptr<ProofVerifyDetails>* verify_details, |
ckrasic | 6567aa5 | 2016-07-08 09:24:35 | [diff] [blame] | 79 | std::unique_ptr<ProofVerifierCallback> callback); |
[email protected] | 5c78ce6 | 2014-03-13 19:48:01 | [diff] [blame] | 80 | |
rtenneti | d073dd2 | 2016-08-04 01:58:33 | [diff] [blame] | 81 | // Starts the certificate chain verification of |certs|. If |QUIC_PENDING| is |
| 82 | // returned, then |callback| will be invoked asynchronously when the |
| 83 | // verification completes. |
| 84 | QuicAsyncStatus VerifyCertChain( |
| 85 | const std::string& hostname, |
| 86 | const std::vector<std::string>& certs, |
| 87 | std::string* error_details, |
| 88 | std::unique_ptr<ProofVerifyDetails>* verify_details, |
| 89 | std::unique_ptr<ProofVerifierCallback> callback); |
| 90 | |
[email protected] | 5c78ce6 | 2014-03-13 19:48:01 | [diff] [blame] | 91 | private: |
| 92 | enum State { |
| 93 | STATE_NONE, |
| 94 | STATE_VERIFY_CERT, |
| 95 | STATE_VERIFY_CERT_COMPLETE, |
| 96 | }; |
| 97 | |
rtenneti | d073dd2 | 2016-08-04 01:58:33 | [diff] [blame] | 98 | // Convert |certs| to |cert_|(X509Certificate). Returns true if successful. |
| 99 | bool GetX509Certificate(const vector<string>& certs, |
| 100 | std::string* error_details, |
| 101 | std::unique_ptr<ProofVerifyDetails>* verify_details); |
| 102 | |
| 103 | // Start the cert verification. |
| 104 | QuicAsyncStatus VerifyCert( |
| 105 | const string& hostname, |
| 106 | const uint16_t port, |
| 107 | std::string* error_details, |
| 108 | std::unique_ptr<ProofVerifyDetails>* verify_details, |
| 109 | std::unique_ptr<ProofVerifierCallback> callback); |
| 110 | |
[email protected] | 5c78ce6 | 2014-03-13 19:48:01 | [diff] [blame] | 111 | int DoLoop(int last_io_result); |
| 112 | void OnIOComplete(int result); |
| 113 | int DoVerifyCert(int result); |
| 114 | int DoVerifyCertComplete(int result); |
| 115 | |
| 116 | bool VerifySignature(const std::string& signed_data, |
rch | 28f6469d | 2016-03-13 21:13:08 | [diff] [blame] | 117 | QuicVersion quic_version, |
| 118 | StringPiece chlo_hash, |
[email protected] | 5c78ce6 | 2014-03-13 19:48:01 | [diff] [blame] | 119 | const std::string& signature, |
| 120 | const std::string& cert); |
| 121 | |
| 122 | // Proof verifier to notify when this jobs completes. |
| 123 | ProofVerifierChromium* proof_verifier_; |
| 124 | |
| 125 | // The underlying verifier used for verifying certificates. |
eroman | 7f9236a | 2015-05-11 21:23:43 | [diff] [blame] | 126 | CertVerifier* verifier_; |
danakj | ad1777e | 2016-04-16 00:56:42 | [diff] [blame] | 127 | std::unique_ptr<CertVerifier::Request> cert_verifier_request_; |
[email protected] | 5c78ce6 | 2014-03-13 19:48:01 | [diff] [blame] | 128 | |
estark | 6f9b3d8 | 2016-01-12 21:37:05 | [diff] [blame] | 129 | CTPolicyEnforcer* policy_enforcer_; |
rsleevi | 9541f863 | 2015-07-31 00:07:00 | [diff] [blame] | 130 | |
[email protected] | 080b7793 | 2014-08-04 01:22:46 | [diff] [blame] | 131 | TransportSecurityState* transport_security_state_; |
| 132 | |
rtenneti | 052774e | 2015-11-24 21:00:12 | [diff] [blame] | 133 | CTVerifier* cert_transparency_verifier_; |
| 134 | |
[email protected] | 5c78ce6 | 2014-03-13 19:48:01 | [diff] [blame] | 135 | // |hostname| specifies the hostname for which |certs| is a valid chain. |
| 136 | std::string hostname_; |
elawrence | 954bb547 | 2016-04-04 22:03:11 | [diff] [blame] | 137 | // |port| specifies the target port for the connection. |
| 138 | uint16_t port_; |
[email protected] | 5c78ce6 | 2014-03-13 19:48:01 | [diff] [blame] | 139 | |
danakj | ad1777e | 2016-04-16 00:56:42 | [diff] [blame] | 140 | std::unique_ptr<ProofVerifierCallback> callback_; |
| 141 | std::unique_ptr<ProofVerifyDetailsChromium> verify_details_; |
[email protected] | 5c78ce6 | 2014-03-13 19:48:01 | [diff] [blame] | 142 | std::string error_details_; |
| 143 | |
| 144 | // X509Certificate from a chain of DER encoded certificates. |
| 145 | scoped_refptr<X509Certificate> cert_; |
| 146 | |
rtenneti | a75df62 | 2015-06-21 23:59:50 | [diff] [blame] | 147 | // |cert_verify_flags| is bitwise OR'd of CertVerifier::VerifyFlags and it is |
| 148 | // passed to CertVerifier::Verify. |
| 149 | int cert_verify_flags_; |
| 150 | |
rtenneti | d073dd2 | 2016-08-04 01:58:33 | [diff] [blame] | 151 | // If set to true, enforces policy checking in DoVerifyCertComplete(). |
| 152 | bool enforce_policy_checking_; |
| 153 | |
[email protected] | 5c78ce6 | 2014-03-13 19:48:01 | [diff] [blame] | 154 | State next_state_; |
| 155 | |
rtenneti | dd4f1bd7 | 2015-12-23 19:17:50 | [diff] [blame] | 156 | base::TimeTicks start_time_; |
| 157 | |
[email protected] | 5c78ce6 | 2014-03-13 19:48:01 | [diff] [blame] | 158 | BoundNetLog net_log_; |
| 159 | |
| 160 | DISALLOW_COPY_AND_ASSIGN(Job); |
| 161 | }; |
| 162 | |
[email protected] | 080b7793 | 2014-08-04 01:22:46 | [diff] [blame] | 163 | ProofVerifierChromium::Job::Job( |
| 164 | ProofVerifierChromium* proof_verifier, |
| 165 | CertVerifier* cert_verifier, |
estark | 6f9b3d8 | 2016-01-12 21:37:05 | [diff] [blame] | 166 | CTPolicyEnforcer* ct_policy_enforcer, |
[email protected] | 080b7793 | 2014-08-04 01:22:46 | [diff] [blame] | 167 | TransportSecurityState* transport_security_state, |
rtenneti | 052774e | 2015-11-24 21:00:12 | [diff] [blame] | 168 | CTVerifier* cert_transparency_verifier, |
rtenneti | a75df62 | 2015-06-21 23:59:50 | [diff] [blame] | 169 | int cert_verify_flags, |
[email protected] | 080b7793 | 2014-08-04 01:22:46 | [diff] [blame] | 170 | const BoundNetLog& net_log) |
[email protected] | 5c78ce6 | 2014-03-13 19:48:01 | [diff] [blame] | 171 | : proof_verifier_(proof_verifier), |
eroman | 7f9236a | 2015-05-11 21:23:43 | [diff] [blame] | 172 | verifier_(cert_verifier), |
estark | 6f9b3d8 | 2016-01-12 21:37:05 | [diff] [blame] | 173 | policy_enforcer_(ct_policy_enforcer), |
[email protected] | 080b7793 | 2014-08-04 01:22:46 | [diff] [blame] | 174 | transport_security_state_(transport_security_state), |
rtenneti | 052774e | 2015-11-24 21:00:12 | [diff] [blame] | 175 | cert_transparency_verifier_(cert_transparency_verifier), |
rtenneti | a75df62 | 2015-06-21 23:59:50 | [diff] [blame] | 176 | cert_verify_flags_(cert_verify_flags), |
rtenneti | d073dd2 | 2016-08-04 01:58:33 | [diff] [blame] | 177 | enforce_policy_checking_(true), |
[email protected] | 5c78ce6 | 2014-03-13 19:48:01 | [diff] [blame] | 178 | next_state_(STATE_NONE), |
rtenneti | dd4f1bd7 | 2015-12-23 19:17:50 | [diff] [blame] | 179 | start_time_(base::TimeTicks::Now()), |
rsleevi | d6de830 | 2016-06-21 01:33:20 | [diff] [blame] | 180 | net_log_(net_log) { |
rsleevi | be81cd6 | 2016-06-24 01:38:59 | [diff] [blame] | 181 | CHECK(proof_verifier_); |
| 182 | CHECK(verifier_); |
| 183 | CHECK(policy_enforcer_); |
| 184 | CHECK(transport_security_state_); |
| 185 | CHECK(cert_transparency_verifier_); |
rsleevi | d6de830 | 2016-06-21 01:33:20 | [diff] [blame] | 186 | } |
[email protected] | 2662ed56 | 2013-07-03 10:27:46 | [diff] [blame] | 187 | |
rtenneti | dd4f1bd7 | 2015-12-23 19:17:50 | [diff] [blame] | 188 | ProofVerifierChromium::Job::~Job() { |
| 189 | base::TimeTicks end_time = base::TimeTicks::Now(); |
| 190 | UMA_HISTOGRAM_TIMES("Net.QuicSession.VerifyProofTime", |
| 191 | end_time - start_time_); |
| 192 | // |hostname_| will always be canonicalized to lowercase. |
| 193 | if (hostname_.compare("www.google.com") == 0) { |
| 194 | UMA_HISTOGRAM_TIMES("Net.QuicSession.VerifyProofTime.google", |
| 195 | end_time - start_time_); |
| 196 | } |
| 197 | } |
| 198 | |
[email protected] | 730b35d7 | 2014-06-05 03:23:22 | [diff] [blame] | 199 | QuicAsyncStatus ProofVerifierChromium::Job::VerifyProof( |
[email protected] | 72e6599 | 2013-07-30 17:16:14 | [diff] [blame] | 200 | const string& hostname, |
elawrence | 954bb547 | 2016-04-04 22:03:11 | [diff] [blame] | 201 | const uint16_t port, |
[email protected] | 72e6599 | 2013-07-30 17:16:14 | [diff] [blame] | 202 | const string& server_config, |
rch | 28f6469d | 2016-03-13 21:13:08 | [diff] [blame] | 203 | QuicVersion quic_version, |
| 204 | StringPiece chlo_hash, |
[email protected] | 72e6599 | 2013-07-30 17:16:14 | [diff] [blame] | 205 | const vector<string>& certs, |
rjshade | c86dbfa | 2015-11-12 20:16:25 | [diff] [blame] | 206 | const std::string& cert_sct, |
[email protected] | 72e6599 | 2013-07-30 17:16:14 | [diff] [blame] | 207 | const string& signature, |
| 208 | std::string* error_details, |
danakj | ad1777e | 2016-04-16 00:56:42 | [diff] [blame] | 209 | std::unique_ptr<ProofVerifyDetails>* verify_details, |
ckrasic | 6567aa5 | 2016-07-08 09:24:35 | [diff] [blame] | 210 | std::unique_ptr<ProofVerifierCallback> callback) { |
[email protected] | 2662ed56 | 2013-07-03 10:27:46 | [diff] [blame] | 211 | DCHECK(error_details); |
[email protected] | c817c67 | 2014-03-21 22:25:34 | [diff] [blame] | 212 | DCHECK(verify_details); |
[email protected] | 72e6599 | 2013-07-30 17:16:14 | [diff] [blame] | 213 | DCHECK(callback); |
| 214 | |
[email protected] | 2662ed56 | 2013-07-03 10:27:46 | [diff] [blame] | 215 | error_details->clear(); |
| 216 | |
[email protected] | 2662ed56 | 2013-07-03 10:27:46 | [diff] [blame] | 217 | if (STATE_NONE != next_state_) { |
| 218 | *error_details = "Certificate is already set and VerifyProof has begun"; |
[email protected] | 5c78ce6 | 2014-03-13 19:48:01 | [diff] [blame] | 219 | DLOG(DFATAL) << *error_details; |
[email protected] | 730b35d7 | 2014-06-05 03:23:22 | [diff] [blame] | 220 | return QUIC_FAILURE; |
[email protected] | 2662ed56 | 2013-07-03 10:27:46 | [diff] [blame] | 221 | } |
| 222 | |
[email protected] | 72e6599 | 2013-07-30 17:16:14 | [diff] [blame] | 223 | verify_details_.reset(new ProofVerifyDetailsChromium); |
| 224 | |
rtenneti | d073dd2 | 2016-08-04 01:58:33 | [diff] [blame] | 225 | // Converts |certs| to |cert_|. |
| 226 | if (!GetX509Certificate(certs, error_details, verify_details)) |
| 227 | return QUIC_FAILURE; |
| 228 | |
| 229 | if (!cert_sct.empty()) { |
| 230 | // Note that this is a completely synchronous operation: The CT Log Verifier |
| 231 | // gets all the data it needs for SCT verification and does not do any |
| 232 | // external communication. |
| 233 | cert_transparency_verifier_->Verify(cert_.get(), std::string(), cert_sct, |
| 234 | &verify_details_->ct_verify_result, |
| 235 | net_log_); |
| 236 | } |
| 237 | |
| 238 | // We call VerifySignature first to avoid copying of server_config and |
| 239 | // signature. |
| 240 | if (!signature.empty() && |
| 241 | !VerifySignature(server_config, quic_version, chlo_hash, signature, |
| 242 | certs[0])) { |
| 243 | *error_details = "Failed to verify signature of server config"; |
| 244 | DLOG(WARNING) << *error_details; |
| 245 | verify_details_->cert_verify_result.cert_status = CERT_STATUS_INVALID; |
| 246 | *verify_details = std::move(verify_details_); |
| 247 | return QUIC_FAILURE; |
| 248 | } |
| 249 | |
| 250 | DCHECK(enforce_policy_checking_); |
| 251 | return VerifyCert(hostname, port, error_details, verify_details, |
| 252 | std::move(callback)); |
| 253 | } |
| 254 | |
| 255 | QuicAsyncStatus ProofVerifierChromium::Job::VerifyCertChain( |
| 256 | const string& hostname, |
| 257 | const vector<string>& certs, |
| 258 | std::string* error_details, |
| 259 | std::unique_ptr<ProofVerifyDetails>* verify_details, |
| 260 | std::unique_ptr<ProofVerifierCallback> callback) { |
| 261 | DCHECK(error_details); |
| 262 | DCHECK(verify_details); |
| 263 | DCHECK(callback); |
| 264 | |
| 265 | error_details->clear(); |
| 266 | |
| 267 | if (STATE_NONE != next_state_) { |
| 268 | *error_details = "Certificate is already set and VerifyCertChain has begun"; |
| 269 | DLOG(DFATAL) << *error_details; |
| 270 | return QUIC_FAILURE; |
| 271 | } |
| 272 | |
| 273 | verify_details_.reset(new ProofVerifyDetailsChromium); |
| 274 | |
| 275 | // Converts |certs| to |cert_|. |
| 276 | if (!GetX509Certificate(certs, error_details, verify_details)) |
| 277 | return QUIC_FAILURE; |
| 278 | |
| 279 | enforce_policy_checking_ = false; |
| 280 | // |port| is not needed because |enforce_policy_checking_| is false. |
| 281 | return VerifyCert(hostname, /*port=*/0, error_details, verify_details, |
| 282 | std::move(callback)); |
| 283 | } |
| 284 | |
| 285 | bool ProofVerifierChromium::Job::GetX509Certificate( |
| 286 | const vector<string>& certs, |
| 287 | std::string* error_details, |
| 288 | std::unique_ptr<ProofVerifyDetails>* verify_details) { |
rtenneti | c14d86fd | 2016-07-10 16:33:34 | [diff] [blame] | 289 | if (certs.empty()) { |
| 290 | *error_details = "Failed to create certificate chain. Certs are empty."; |
| 291 | DLOG(WARNING) << *error_details; |
| 292 | verify_details_->cert_verify_result.cert_status = CERT_STATUS_INVALID; |
| 293 | *verify_details = std::move(verify_details_); |
rtenneti | d073dd2 | 2016-08-04 01:58:33 | [diff] [blame] | 294 | return false; |
rtenneti | c14d86fd | 2016-07-10 16:33:34 | [diff] [blame] | 295 | } |
| 296 | |
| 297 | // Convert certs to X509Certificate. |
| 298 | vector<StringPiece> cert_pieces(certs.size()); |
| 299 | for (unsigned i = 0; i < certs.size(); i++) { |
| 300 | cert_pieces[i] = base::StringPiece(certs[i]); |
| 301 | } |
| 302 | cert_ = X509Certificate::CreateFromDERCertChain(cert_pieces); |
| 303 | if (!cert_.get()) { |
| 304 | *error_details = "Failed to create certificate chain"; |
| 305 | DLOG(WARNING) << *error_details; |
| 306 | verify_details_->cert_verify_result.cert_status = CERT_STATUS_INVALID; |
| 307 | *verify_details = std::move(verify_details_); |
rtenneti | d073dd2 | 2016-08-04 01:58:33 | [diff] [blame] | 308 | return false; |
rtenneti | c14d86fd | 2016-07-10 16:33:34 | [diff] [blame] | 309 | } |
rtenneti | d073dd2 | 2016-08-04 01:58:33 | [diff] [blame] | 310 | return true; |
| 311 | } |
[email protected] | 2662ed56 | 2013-07-03 10:27:46 | [diff] [blame] | 312 | |
rtenneti | d073dd2 | 2016-08-04 01:58:33 | [diff] [blame] | 313 | QuicAsyncStatus ProofVerifierChromium::Job::VerifyCert( |
| 314 | const string& hostname, |
| 315 | const uint16_t port, |
| 316 | std::string* error_details, |
| 317 | std::unique_ptr<ProofVerifyDetails>* verify_details, |
| 318 | std::unique_ptr<ProofVerifierCallback> callback) { |
[email protected] | 2662ed56 | 2013-07-03 10:27:46 | [diff] [blame] | 319 | hostname_ = hostname; |
elawrence | 954bb547 | 2016-04-04 22:03:11 | [diff] [blame] | 320 | port_ = port; |
[email protected] | 2662ed56 | 2013-07-03 10:27:46 | [diff] [blame] | 321 | |
| 322 | next_state_ = STATE_VERIFY_CERT; |
[email protected] | 72e6599 | 2013-07-30 17:16:14 | [diff] [blame] | 323 | switch (DoLoop(OK)) { |
| 324 | case OK: |
dcheng | c7eeda42 | 2015-12-26 03:56:48 | [diff] [blame] | 325 | *verify_details = std::move(verify_details_); |
[email protected] | 730b35d7 | 2014-06-05 03:23:22 | [diff] [blame] | 326 | return QUIC_SUCCESS; |
[email protected] | 72e6599 | 2013-07-30 17:16:14 | [diff] [blame] | 327 | case ERR_IO_PENDING: |
ckrasic | 6567aa5 | 2016-07-08 09:24:35 | [diff] [blame] | 328 | callback_ = std::move(callback); |
[email protected] | 730b35d7 | 2014-06-05 03:23:22 | [diff] [blame] | 329 | return QUIC_PENDING; |
[email protected] | 72e6599 | 2013-07-30 17:16:14 | [diff] [blame] | 330 | default: |
| 331 | *error_details = error_details_; |
dcheng | c7eeda42 | 2015-12-26 03:56:48 | [diff] [blame] | 332 | *verify_details = std::move(verify_details_); |
[email protected] | 730b35d7 | 2014-06-05 03:23:22 | [diff] [blame] | 333 | return QUIC_FAILURE; |
[email protected] | 72e6599 | 2013-07-30 17:16:14 | [diff] [blame] | 334 | } |
[email protected] | 2662ed56 | 2013-07-03 10:27:46 | [diff] [blame] | 335 | } |
| 336 | |
[email protected] | 5c78ce6 | 2014-03-13 19:48:01 | [diff] [blame] | 337 | int ProofVerifierChromium::Job::DoLoop(int last_result) { |
[email protected] | 2662ed56 | 2013-07-03 10:27:46 | [diff] [blame] | 338 | int rv = last_result; |
| 339 | do { |
| 340 | State state = next_state_; |
| 341 | next_state_ = STATE_NONE; |
| 342 | switch (state) { |
| 343 | case STATE_VERIFY_CERT: |
| 344 | DCHECK(rv == OK); |
| 345 | rv = DoVerifyCert(rv); |
| 346 | break; |
| 347 | case STATE_VERIFY_CERT_COMPLETE: |
| 348 | rv = DoVerifyCertComplete(rv); |
| 349 | break; |
| 350 | case STATE_NONE: |
| 351 | default: |
| 352 | rv = ERR_UNEXPECTED; |
| 353 | LOG(DFATAL) << "unexpected state " << state; |
| 354 | break; |
| 355 | } |
| 356 | } while (rv != ERR_IO_PENDING && next_state_ != STATE_NONE); |
| 357 | return rv; |
| 358 | } |
| 359 | |
[email protected] | 5c78ce6 | 2014-03-13 19:48:01 | [diff] [blame] | 360 | void ProofVerifierChromium::Job::OnIOComplete(int result) { |
[email protected] | 2662ed56 | 2013-07-03 10:27:46 | [diff] [blame] | 361 | int rv = DoLoop(result); |
| 362 | if (rv != ERR_IO_PENDING) { |
danakj | ad1777e | 2016-04-16 00:56:42 | [diff] [blame] | 363 | std::unique_ptr<ProofVerifierCallback> callback(std::move(callback_)); |
[email protected] | 5c78ce6 | 2014-03-13 19:48:01 | [diff] [blame] | 364 | // Callback expects ProofVerifyDetails not ProofVerifyDetailsChromium. |
danakj | ad1777e | 2016-04-16 00:56:42 | [diff] [blame] | 365 | std::unique_ptr<ProofVerifyDetails> verify_details( |
| 366 | std::move(verify_details_)); |
[email protected] | 5c78ce6 | 2014-03-13 19:48:01 | [diff] [blame] | 367 | callback->Run(rv == OK, error_details_, &verify_details); |
| 368 | // Will delete |this|. |
| 369 | proof_verifier_->OnJobComplete(this); |
[email protected] | 2662ed56 | 2013-07-03 10:27:46 | [diff] [blame] | 370 | } |
| 371 | } |
| 372 | |
[email protected] | 5c78ce6 | 2014-03-13 19:48:01 | [diff] [blame] | 373 | int ProofVerifierChromium::Job::DoVerifyCert(int result) { |
[email protected] | 2662ed56 | 2013-07-03 10:27:46 | [diff] [blame] | 374 | next_state_ = STATE_VERIFY_CERT_COMPLETE; |
| 375 | |
rtenneti | a75df62 | 2015-06-21 23:59:50 | [diff] [blame] | 376 | return verifier_->Verify( |
rsleevi | 06bd7855 | 2016-06-08 22:34:46 | [diff] [blame] | 377 | CertVerifier::RequestParams(cert_, hostname_, cert_verify_flags_, |
| 378 | std::string(), CertificateList()), |
rtenneti | a75df62 | 2015-06-21 23:59:50 | [diff] [blame] | 379 | SSLConfigService::GetCRLSet().get(), &verify_details_->cert_verify_result, |
| 380 | base::Bind(&ProofVerifierChromium::Job::OnIOComplete, |
| 381 | base::Unretained(this)), |
| 382 | &cert_verifier_request_, net_log_); |
[email protected] | 2662ed56 | 2013-07-03 10:27:46 | [diff] [blame] | 383 | } |
| 384 | |
[email protected] | 5c78ce6 | 2014-03-13 19:48:01 | [diff] [blame] | 385 | int ProofVerifierChromium::Job::DoVerifyCertComplete(int result) { |
eroman | 7f9236a | 2015-05-11 21:23:43 | [diff] [blame] | 386 | cert_verifier_request_.reset(); |
[email protected] | 2662ed56 | 2013-07-03 10:27:46 | [diff] [blame] | 387 | |
[email protected] | 080b7793 | 2014-08-04 01:22:46 | [diff] [blame] | 388 | const CertVerifyResult& cert_verify_result = |
| 389 | verify_details_->cert_verify_result; |
[email protected] | 080b7793 | 2014-08-04 01:22:46 | [diff] [blame] | 390 | const CertStatus cert_status = cert_verify_result.cert_status; |
rsleevi | d6de830 | 2016-06-21 01:33:20 | [diff] [blame] | 391 | verify_details_->ct_verify_result.ct_policies_applied = result == OK; |
estark | 723b5eeb | 2016-02-18 21:01:12 | [diff] [blame] | 392 | verify_details_->ct_verify_result.ev_policy_compliance = |
| 393 | ct::EVPolicyCompliance::EV_POLICY_DOES_NOT_APPLY; |
rsleevi | 4a6ca8c | 2016-06-24 03:05:22 | [diff] [blame] | 394 | |
| 395 | // If the connection was good, check HPKP and CT status simultaneously, |
| 396 | // but prefer to treat the HPKP error as more serious, if there was one. |
rtenneti | d073dd2 | 2016-08-04 01:58:33 | [diff] [blame] | 397 | if (enforce_policy_checking_ && |
| 398 | (result == OK || |
rsleevi | 4a6ca8c | 2016-06-24 03:05:22 | [diff] [blame] | 399 | (IsCertificateError(result) && IsCertStatusMinorError(cert_status)))) { |
eranm | 4bed0b57 | 2016-08-14 21:00:35 | [diff] [blame^] | 400 | SCTList verified_scts = ct::SCTsMatchingStatus( |
| 401 | verify_details_->ct_verify_result.scts, ct::SCT_STATUS_OK); |
estark | 0fc8d078 | 2016-02-25 20:41:20 | [diff] [blame] | 402 | if ((cert_verify_result.cert_status & CERT_STATUS_IS_EV)) { |
| 403 | ct::EVPolicyCompliance ev_policy_compliance = |
| 404 | policy_enforcer_->DoesConformToCTEVPolicy( |
| 405 | cert_verify_result.verified_cert.get(), |
eranm | 4bed0b57 | 2016-08-14 21:00:35 | [diff] [blame^] | 406 | SSLConfigService::GetEVCertsWhitelist().get(), verified_scts, |
| 407 | net_log_); |
estark | 0fc8d078 | 2016-02-25 20:41:20 | [diff] [blame] | 408 | verify_details_->ct_verify_result.ev_policy_compliance = |
| 409 | ev_policy_compliance; |
| 410 | if (ev_policy_compliance != |
| 411 | ct::EVPolicyCompliance::EV_POLICY_DOES_NOT_APPLY && |
| 412 | ev_policy_compliance != |
| 413 | ct::EVPolicyCompliance::EV_POLICY_COMPLIES_VIA_WHITELIST && |
| 414 | ev_policy_compliance != |
| 415 | ct::EVPolicyCompliance::EV_POLICY_COMPLIES_VIA_SCTS) { |
| 416 | verify_details_->cert_verify_result.cert_status |= |
| 417 | CERT_STATUS_CT_COMPLIANCE_FAILED; |
| 418 | verify_details_->cert_verify_result.cert_status &= ~CERT_STATUS_IS_EV; |
| 419 | } |
rsleevi | 9541f863 | 2015-07-31 00:07:00 | [diff] [blame] | 420 | } |
estark | 0fc8d078 | 2016-02-25 20:41:20 | [diff] [blame] | 421 | |
| 422 | verify_details_->ct_verify_result.cert_policy_compliance = |
| 423 | policy_enforcer_->DoesConformToCertPolicy( |
eranm | 4bed0b57 | 2016-08-14 21:00:35 | [diff] [blame^] | 424 | cert_verify_result.verified_cert.get(), verified_scts, net_log_); |
rsleevi | 9541f863 | 2015-07-31 00:07:00 | [diff] [blame] | 425 | |
rsleevi | 4a6ca8c | 2016-06-24 03:05:22 | [diff] [blame] | 426 | int ct_result = OK; |
| 427 | if (verify_details_->ct_verify_result.cert_policy_compliance != |
| 428 | ct::CertPolicyCompliance::CERT_POLICY_COMPLIES_VIA_SCTS && |
| 429 | transport_security_state_->ShouldRequireCT( |
| 430 | hostname_, cert_verify_result.verified_cert.get(), |
| 431 | cert_verify_result.public_key_hashes)) { |
| 432 | verify_details_->cert_verify_result.cert_status |= |
| 433 | CERT_STATUS_CERTIFICATE_TRANSPARENCY_REQUIRED; |
| 434 | ct_result = ERR_CERTIFICATE_TRANSPARENCY_REQUIRED; |
| 435 | } |
| 436 | |
dadrian | 8f894665 | 2016-06-21 23:48:31 | [diff] [blame] | 437 | TransportSecurityState::PKPStatus pin_validity = |
| 438 | transport_security_state_->CheckPublicKeyPins( |
| 439 | HostPortPair(hostname_, port_), |
| 440 | cert_verify_result.is_issued_by_known_root, |
| 441 | cert_verify_result.public_key_hashes, cert_.get(), |
| 442 | cert_verify_result.verified_cert.get(), |
| 443 | TransportSecurityState::ENABLE_PIN_REPORTS, |
| 444 | &verify_details_->pinning_failure_log); |
| 445 | switch (pin_validity) { |
| 446 | case TransportSecurityState::PKPStatus::VIOLATED: |
| 447 | result = ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN; |
| 448 | verify_details_->cert_verify_result.cert_status |= |
| 449 | CERT_STATUS_PINNED_KEY_MISSING; |
| 450 | break; |
| 451 | case TransportSecurityState::PKPStatus::BYPASSED: |
| 452 | verify_details_->pkp_bypassed = true; |
| 453 | // Fall through. |
| 454 | case TransportSecurityState::PKPStatus::OK: |
| 455 | // Do nothing. |
| 456 | break; |
rsleevi | 9545d34 | 2016-06-21 03:17:37 | [diff] [blame] | 457 | } |
rsleevi | 4a6ca8c | 2016-06-24 03:05:22 | [diff] [blame] | 458 | if (result != ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN && ct_result != OK) |
| 459 | result = ct_result; |
[email protected] | 080b7793 | 2014-08-04 01:22:46 | [diff] [blame] | 460 | } |
[email protected] | 080b7793 | 2014-08-04 01:22:46 | [diff] [blame] | 461 | |
[email protected] | 0cceb92 | 2014-07-01 02:00:56 | [diff] [blame] | 462 | if (result != OK) { |
[email protected] | 3030374e3 | 2014-08-07 16:12:06 | [diff] [blame] | 463 | std::string error_string = ErrorToString(result); |
[email protected] | 72e6599 | 2013-07-30 17:16:14 | [diff] [blame] | 464 | error_details_ = StringPrintf("Failed to verify certificate chain: %s", |
[email protected] | 3030374e3 | 2014-08-07 16:12:06 | [diff] [blame] | 465 | error_string.c_str()); |
[email protected] | 72e6599 | 2013-07-30 17:16:14 | [diff] [blame] | 466 | DLOG(WARNING) << error_details_; |
[email protected] | 2662ed56 | 2013-07-03 10:27:46 | [diff] [blame] | 467 | } |
| 468 | |
| 469 | // Exit DoLoop and return the result to the caller to VerifyProof. |
| 470 | DCHECK_EQ(STATE_NONE, next_state_); |
| 471 | return result; |
| 472 | } |
| 473 | |
[email protected] | 5c78ce6 | 2014-03-13 19:48:01 | [diff] [blame] | 474 | bool ProofVerifierChromium::Job::VerifySignature(const string& signed_data, |
rch | 28f6469d | 2016-03-13 21:13:08 | [diff] [blame] | 475 | QuicVersion quic_version, |
| 476 | StringPiece chlo_hash, |
[email protected] | 3030374e3 | 2014-08-07 16:12:06 | [diff] [blame] | 477 | const string& signature, |
| 478 | const string& cert) { |
[email protected] | 2662ed56 | 2013-07-03 10:27:46 | [diff] [blame] | 479 | StringPiece spki; |
| 480 | if (!asn1::ExtractSPKIFromDERCert(cert, &spki)) { |
| 481 | DLOG(WARNING) << "ExtractSPKIFromDERCert failed"; |
| 482 | return false; |
| 483 | } |
| 484 | |
| 485 | crypto::SignatureVerifier verifier; |
| 486 | |
| 487 | size_t size_bits; |
| 488 | X509Certificate::PublicKeyType type; |
rjshade | d5ced07 | 2015-12-18 19:26:02 | [diff] [blame] | 489 | X509Certificate::GetPublicKeyInfo(cert_->os_cert_handle(), &size_bits, &type); |
[email protected] | 2662ed56 | 2013-07-03 10:27:46 | [diff] [blame] | 490 | if (type == X509Certificate::kPublicKeyTypeRSA) { |
| 491 | crypto::SignatureVerifier::HashAlgorithm hash_alg = |
| 492 | crypto::SignatureVerifier::SHA256; |
| 493 | crypto::SignatureVerifier::HashAlgorithm mask_hash_alg = hash_alg; |
| 494 | unsigned int hash_len = 32; // 32 is the length of a SHA-256 hash. |
[email protected] | 2662ed56 | 2013-07-03 10:27:46 | [diff] [blame] | 495 | |
| 496 | bool ok = verifier.VerifyInitRSAPSS( |
[email protected] | d5c9e4ba | 2013-09-14 05:25:58 | [diff] [blame] | 497 | hash_alg, mask_hash_alg, hash_len, |
Avi Drissman | 13fc893 | 2015-12-20 04:40:46 | [diff] [blame] | 498 | reinterpret_cast<const uint8_t*>(signature.data()), signature.size(), |
| 499 | reinterpret_cast<const uint8_t*>(spki.data()), spki.size()); |
[email protected] | 2662ed56 | 2013-07-03 10:27:46 | [diff] [blame] | 500 | if (!ok) { |
| 501 | DLOG(WARNING) << "VerifyInitRSAPSS failed"; |
| 502 | return false; |
| 503 | } |
| 504 | } else if (type == X509Certificate::kPublicKeyTypeECDSA) { |
davidben | 9c97a36 | 2016-03-03 16:18:26 | [diff] [blame] | 505 | if (!verifier.VerifyInit(crypto::SignatureVerifier::ECDSA_SHA256, |
| 506 | reinterpret_cast<const uint8_t*>(signature.data()), |
| 507 | signature.size(), |
| 508 | reinterpret_cast<const uint8_t*>(spki.data()), |
| 509 | spki.size())) { |
[email protected] | 2662ed56 | 2013-07-03 10:27:46 | [diff] [blame] | 510 | DLOG(WARNING) << "VerifyInit failed"; |
| 511 | return false; |
| 512 | } |
| 513 | } else { |
| 514 | LOG(ERROR) << "Unsupported public key type " << type; |
| 515 | return false; |
| 516 | } |
| 517 | |
rch | 28f6469d | 2016-03-13 21:13:08 | [diff] [blame] | 518 | if (quic_version <= QUIC_VERSION_30) { |
| 519 | verifier.VerifyUpdate( |
| 520 | reinterpret_cast<const uint8_t*>(kProofSignatureLabelOld), |
| 521 | sizeof(kProofSignatureLabelOld)); |
| 522 | } else { |
| 523 | verifier.VerifyUpdate( |
| 524 | reinterpret_cast<const uint8_t*>(kProofSignatureLabel), |
| 525 | sizeof(kProofSignatureLabel)); |
| 526 | uint32_t len = chlo_hash.length(); |
| 527 | verifier.VerifyUpdate(reinterpret_cast<const uint8_t*>(&len), sizeof(len)); |
| 528 | verifier.VerifyUpdate(reinterpret_cast<const uint8_t*>(chlo_hash.data()), |
| 529 | len); |
| 530 | } |
| 531 | |
Avi Drissman | 13fc893 | 2015-12-20 04:40:46 | [diff] [blame] | 532 | verifier.VerifyUpdate(reinterpret_cast<const uint8_t*>(signed_data.data()), |
[email protected] | 2662ed56 | 2013-07-03 10:27:46 | [diff] [blame] | 533 | signed_data.size()); |
| 534 | |
| 535 | if (!verifier.VerifyFinal()) { |
| 536 | DLOG(WARNING) << "VerifyFinal failed"; |
| 537 | return false; |
| 538 | } |
| 539 | |
[email protected] | 3e5fed1 | 2013-11-22 22:21:41 | [diff] [blame] | 540 | DVLOG(1) << "VerifyFinal success"; |
[email protected] | 2662ed56 | 2013-07-03 10:27:46 | [diff] [blame] | 541 | return true; |
| 542 | } |
| 543 | |
[email protected] | 080b7793 | 2014-08-04 01:22:46 | [diff] [blame] | 544 | ProofVerifierChromium::ProofVerifierChromium( |
| 545 | CertVerifier* cert_verifier, |
estark | 6f9b3d8 | 2016-01-12 21:37:05 | [diff] [blame] | 546 | CTPolicyEnforcer* ct_policy_enforcer, |
rtenneti | 052774e | 2015-11-24 21:00:12 | [diff] [blame] | 547 | TransportSecurityState* transport_security_state, |
| 548 | CTVerifier* cert_transparency_verifier) |
[email protected] | 080b7793 | 2014-08-04 01:22:46 | [diff] [blame] | 549 | : cert_verifier_(cert_verifier), |
estark | 6f9b3d8 | 2016-01-12 21:37:05 | [diff] [blame] | 550 | ct_policy_enforcer_(ct_policy_enforcer), |
rtenneti | 052774e | 2015-11-24 21:00:12 | [diff] [blame] | 551 | transport_security_state_(transport_security_state), |
rsleevi | d6de830 | 2016-06-21 01:33:20 | [diff] [blame] | 552 | cert_transparency_verifier_(cert_transparency_verifier) { |
| 553 | DCHECK(cert_verifier_); |
| 554 | DCHECK(ct_policy_enforcer_); |
| 555 | DCHECK(transport_security_state_); |
| 556 | DCHECK(cert_transparency_verifier_); |
| 557 | } |
[email protected] | 5c78ce6 | 2014-03-13 19:48:01 | [diff] [blame] | 558 | |
| 559 | ProofVerifierChromium::~ProofVerifierChromium() { |
skyostil | b8f60ca | 2016-08-12 12:34:43 | [diff] [blame] | 560 | base::STLDeleteElements(&active_jobs_); |
[email protected] | 5c78ce6 | 2014-03-13 19:48:01 | [diff] [blame] | 561 | } |
| 562 | |
[email protected] | 730b35d7 | 2014-06-05 03:23:22 | [diff] [blame] | 563 | QuicAsyncStatus ProofVerifierChromium::VerifyProof( |
[email protected] | 5c78ce6 | 2014-03-13 19:48:01 | [diff] [blame] | 564 | const std::string& hostname, |
elawrence | 954bb547 | 2016-04-04 22:03:11 | [diff] [blame] | 565 | const uint16_t port, |
[email protected] | 5c78ce6 | 2014-03-13 19:48:01 | [diff] [blame] | 566 | const std::string& server_config, |
rch | 28f6469d | 2016-03-13 21:13:08 | [diff] [blame] | 567 | QuicVersion quic_version, |
| 568 | base::StringPiece chlo_hash, |
[email protected] | 5c78ce6 | 2014-03-13 19:48:01 | [diff] [blame] | 569 | const std::vector<std::string>& certs, |
rjshade | c86dbfa | 2015-11-12 20:16:25 | [diff] [blame] | 570 | const std::string& cert_sct, |
[email protected] | 5c78ce6 | 2014-03-13 19:48:01 | [diff] [blame] | 571 | const std::string& signature, |
[email protected] | c817c67 | 2014-03-21 22:25:34 | [diff] [blame] | 572 | const ProofVerifyContext* verify_context, |
[email protected] | 5c78ce6 | 2014-03-13 19:48:01 | [diff] [blame] | 573 | std::string* error_details, |
danakj | ad1777e | 2016-04-16 00:56:42 | [diff] [blame] | 574 | std::unique_ptr<ProofVerifyDetails>* verify_details, |
ckrasic | 6567aa5 | 2016-07-08 09:24:35 | [diff] [blame] | 575 | std::unique_ptr<ProofVerifierCallback> callback) { |
[email protected] | c817c67 | 2014-03-21 22:25:34 | [diff] [blame] | 576 | if (!verify_context) { |
| 577 | *error_details = "Missing context"; |
[email protected] | 730b35d7 | 2014-06-05 03:23:22 | [diff] [blame] | 578 | return QUIC_FAILURE; |
[email protected] | c817c67 | 2014-03-21 22:25:34 | [diff] [blame] | 579 | } |
| 580 | const ProofVerifyContextChromium* chromium_context = |
| 581 | reinterpret_cast<const ProofVerifyContextChromium*>(verify_context); |
danakj | ad1777e | 2016-04-16 00:56:42 | [diff] [blame] | 582 | std::unique_ptr<Job> job( |
estark | 6f9b3d8 | 2016-01-12 21:37:05 | [diff] [blame] | 583 | new Job(this, cert_verifier_, ct_policy_enforcer_, |
rtenneti | 052774e | 2015-11-24 21:00:12 | [diff] [blame] | 584 | transport_security_state_, cert_transparency_verifier_, |
| 585 | chromium_context->cert_verify_flags, chromium_context->net_log)); |
rch | 28f6469d | 2016-03-13 21:13:08 | [diff] [blame] | 586 | QuicAsyncStatus status = job->VerifyProof( |
elawrence | 954bb547 | 2016-04-04 22:03:11 | [diff] [blame] | 587 | hostname, port, server_config, quic_version, chlo_hash, certs, cert_sct, |
ckrasic | 6567aa5 | 2016-07-08 09:24:35 | [diff] [blame] | 588 | signature, error_details, verify_details, std::move(callback)); |
rtenneti | d073dd2 | 2016-08-04 01:58:33 | [diff] [blame] | 589 | if (status == QUIC_PENDING) |
[email protected] | 5c78ce6 | 2014-03-13 19:48:01 | [diff] [blame] | 590 | active_jobs_.insert(job.release()); |
rtenneti | d073dd2 | 2016-08-04 01:58:33 | [diff] [blame] | 591 | return status; |
| 592 | } |
| 593 | |
| 594 | QuicAsyncStatus ProofVerifierChromium::VerifyCertChain( |
| 595 | const std::string& hostname, |
| 596 | const std::vector<std::string>& certs, |
| 597 | const ProofVerifyContext* verify_context, |
| 598 | std::string* error_details, |
| 599 | std::unique_ptr<ProofVerifyDetails>* verify_details, |
| 600 | std::unique_ptr<ProofVerifierCallback> callback) { |
| 601 | if (!verify_context) { |
| 602 | *error_details = "Missing context"; |
| 603 | return QUIC_FAILURE; |
[email protected] | 5c78ce6 | 2014-03-13 19:48:01 | [diff] [blame] | 604 | } |
rtenneti | d073dd2 | 2016-08-04 01:58:33 | [diff] [blame] | 605 | const ProofVerifyContextChromium* chromium_context = |
| 606 | reinterpret_cast<const ProofVerifyContextChromium*>(verify_context); |
| 607 | std::unique_ptr<Job> job( |
| 608 | new Job(this, cert_verifier_, ct_policy_enforcer_, |
| 609 | transport_security_state_, cert_transparency_verifier_, |
| 610 | chromium_context->cert_verify_flags, chromium_context->net_log)); |
| 611 | QuicAsyncStatus status = job->VerifyCertChain( |
| 612 | hostname, certs, error_details, verify_details, std::move(callback)); |
| 613 | if (status == QUIC_PENDING) |
| 614 | active_jobs_.insert(job.release()); |
[email protected] | 5c78ce6 | 2014-03-13 19:48:01 | [diff] [blame] | 615 | return status; |
| 616 | } |
| 617 | |
| 618 | void ProofVerifierChromium::OnJobComplete(Job* job) { |
| 619 | active_jobs_.erase(job); |
| 620 | delete job; |
| 621 | } |
| 622 | |
[email protected] | 2662ed56 | 2013-07-03 10:27:46 | [diff] [blame] | 623 | } // namespace net |