OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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/quic/crypto/proof_verifier_chromium.h" | 5 #include "net/quic/crypto/proof_verifier_chromium.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 22 matching lines...) Expand all Loading... | |
33 ProofVerifierChromium::ProofVerifierChromium(CertVerifier* cert_verifier, | 33 ProofVerifierChromium::ProofVerifierChromium(CertVerifier* cert_verifier, |
34 const BoundNetLog& net_log) | 34 const BoundNetLog& net_log) |
35 : cert_verifier_(cert_verifier), | 35 : cert_verifier_(cert_verifier), |
36 error_details_(NULL), | 36 error_details_(NULL), |
37 next_state_(STATE_NONE), | 37 next_state_(STATE_NONE), |
38 net_log_(net_log) { | 38 net_log_(net_log) { |
39 } | 39 } |
40 | 40 |
41 ProofVerifierChromium::~ProofVerifierChromium() { | 41 ProofVerifierChromium::~ProofVerifierChromium() { |
42 verifier_.reset(); | 42 verifier_.reset(); |
43 | |
44 // Reset object state. | |
45 callback_.Reset(); | |
46 cert_verify_result_.Reset(); | |
wtc
2013/07/03 19:06:58
Thank you for making this change. I confirmed tha
| |
47 } | 43 } |
48 | 44 |
49 int ProofVerifierChromium::VerifyProof(const string& hostname, | 45 int ProofVerifierChromium::VerifyProof(const string& hostname, |
50 const string& server_config, | 46 const string& server_config, |
51 const vector<string>& certs, | 47 const vector<string>& certs, |
52 const string& signature, | 48 const string& signature, |
53 std::string* error_details, | 49 std::string* error_details, |
54 const CompletionCallback& callback) { | 50 const CompletionCallback& callback) { |
55 DCHECK(error_details); | 51 DCHECK(error_details); |
56 error_details->clear(); | 52 error_details->clear(); |
(...skipping 11 matching lines...) Expand all Loading... | |
68 return ERR_FAILED; | 64 return ERR_FAILED; |
69 } | 65 } |
70 | 66 |
71 // Convert certs to X509Certificate. | 67 // Convert certs to X509Certificate. |
72 vector<StringPiece> cert_pieces(certs.size()); | 68 vector<StringPiece> cert_pieces(certs.size()); |
73 for (unsigned i = 0; i < certs.size(); i++) { | 69 for (unsigned i = 0; i < certs.size(); i++) { |
74 cert_pieces[i] = base::StringPiece(certs[i]); | 70 cert_pieces[i] = base::StringPiece(certs[i]); |
75 } | 71 } |
76 cert_ = X509Certificate::CreateFromDERCertChain(cert_pieces); | 72 cert_ = X509Certificate::CreateFromDERCertChain(cert_pieces); |
77 if (!cert_.get()) { | 73 if (!cert_.get()) { |
78 cert_verify_result_.Reset(); | 74 cert_verify_result_.Reset(); |
wtc
2013/07/03 19:06:58
This line should be removed, too.
ramant (doing other things)
2013/07/03 20:31:35
Done.
| |
79 cert_verify_result_.cert_status = CERT_STATUS_INVALID; | |
80 *error_details = "Failed to create certificate chain"; | 75 *error_details = "Failed to create certificate chain"; |
81 DLOG(WARNING) << *error_details; | 76 DLOG(WARNING) << *error_details; |
82 return ERR_FAILED; | 77 return ERR_FAILED; |
83 } | 78 } |
84 | 79 |
85 // We call VerifySignature first to avoid copying of server_config and | 80 // We call VerifySignature first to avoid copying of server_config and |
86 // signature. | 81 // signature. |
87 if (!VerifySignature(server_config, signature, certs[0])) { | 82 if (!VerifySignature(server_config, signature, certs[0])) { |
88 *error_details = "Failed to verify signature of server config"; | 83 *error_details = "Failed to verify signature of server config"; |
89 DLOG(WARNING) << *error_details; | 84 DLOG(WARNING) << *error_details; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
142 base::Bind(&ProofVerifierChromium::OnIOComplete, | 137 base::Bind(&ProofVerifierChromium::OnIOComplete, |
143 base::Unretained(this)), | 138 base::Unretained(this)), |
144 net_log_); | 139 net_log_); |
145 } | 140 } |
146 | 141 |
147 int ProofVerifierChromium::DoVerifyCertComplete(int result) { | 142 int ProofVerifierChromium::DoVerifyCertComplete(int result) { |
148 verifier_.reset(); | 143 verifier_.reset(); |
149 | 144 |
150 if (result <= ERR_FAILED) { | 145 if (result <= ERR_FAILED) { |
151 *error_details_ = StringPrintf("Failed to verify certificate chain: %s", | 146 *error_details_ = StringPrintf("Failed to verify certificate chain: %s", |
152 ErrorToString(result)); | 147 ErrorToString(result)); |
153 DLOG(WARNING) << *error_details_; | 148 DLOG(WARNING) << *error_details_; |
154 result = ERR_FAILED; | 149 result = ERR_FAILED; |
155 } | 150 } |
156 | 151 |
157 // Exit DoLoop and return the result to the caller to VerifyProof. | 152 // Exit DoLoop and return the result to the caller to VerifyProof. |
158 DCHECK_EQ(STATE_NONE, next_state_); | 153 DCHECK_EQ(STATE_NONE, next_state_); |
159 return result; | 154 return result; |
160 } | 155 } |
161 | 156 |
162 bool ProofVerifierChromium::VerifySignature(const string& signed_data, | 157 bool ProofVerifierChromium::VerifySignature(const string& signed_data, |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
231 if (!verifier.VerifyFinal()) { | 226 if (!verifier.VerifyFinal()) { |
232 DLOG(WARNING) << "VerifyFinal failed"; | 227 DLOG(WARNING) << "VerifyFinal failed"; |
233 return false; | 228 return false; |
234 } | 229 } |
235 | 230 |
236 DLOG(INFO) << "VerifyFinal success"; | 231 DLOG(INFO) << "VerifyFinal success"; |
237 return true; | 232 return true; |
238 } | 233 } |
239 | 234 |
240 } // namespace net | 235 } // namespace net |
OLD | NEW |