Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(181)

Side by Side Diff: net/tools/quic/test_tools/quic_test_client.cc

Issue 20047002: net: make QUIC ProofVerifier more generic. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Can't use a token called "ERROR" on Windows. Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "net/tools/quic/test_tools/quic_test_client.h" 5 #include "net/tools/quic/test_tools/quic_test_client.h"
6 6
7 #include "net/base/completion_callback.h" 7 #include "net/base/completion_callback.h"
8 #include "net/base/net_errors.h" 8 #include "net/base/net_errors.h"
9 #include "net/cert/cert_verify_result.h" 9 #include "net/cert/cert_verify_result.h"
10 #include "net/cert/x509_certificate.h" 10 #include "net/cert/x509_certificate.h"
11 #include "net/quic/crypto/proof_verifier.h" 11 #include "net/quic/crypto/proof_verifier.h"
12 #include "net/tools/flip_server/balsa_headers.h" 12 #include "net/tools/flip_server/balsa_headers.h"
13 #include "net/tools/quic/test_tools/http_message_test_utils.h" 13 #include "net/tools/quic/test_tools/http_message_test_utils.h"
14 #include "url/gurl.h" 14 #include "url/gurl.h"
15 15
16 using std::string; 16 using std::string;
17 using std::vector; 17 using std::vector;
18 using base::StringPiece; 18 using base::StringPiece;
19 19
20 namespace { 20 namespace {
21 21
22 // RecordingProofVerifier accepts any certificate chain and records the common 22 // RecordingProofVerifier accepts any certificate chain and records the common
23 // name of the leaf. 23 // name of the leaf.
24 class RecordingProofVerifier : public net::ProofVerifier { 24 class RecordingProofVerifier : public net::ProofVerifier {
25 public: 25 public:
26 // ProofVerifier interface. 26 // ProofVerifier interface.
27 virtual int VerifyProof(const string& hostname, 27 virtual net::ProofVerifier::Status VerifyProof(
28 const string& server_config, 28 const string& hostname,
29 const vector<string>& certs, 29 const string& server_config,
30 const string& signature, 30 const vector<string>& certs,
31 string* error_details, 31 const string& signature,
32 net::CertVerifyResult* cert_verify_result, 32 string* error_details,
33 const net::CompletionCallback& callback) OVERRIDE { 33 scoped_ptr<net::ProofVerifyDetails>* details,
34 net::ProofVerifierCallback* callback) OVERRIDE {
35 delete callback;
36
34 common_name_.clear(); 37 common_name_.clear();
35 if (certs.empty()) { 38 if (certs.empty()) {
36 return net::ERR_FAILED; 39 return FAILURE;
37 } 40 }
38 41
39 // Convert certs to X509Certificate. 42 // Convert certs to X509Certificate.
40 vector<StringPiece> cert_pieces(certs.size()); 43 vector<StringPiece> cert_pieces(certs.size());
41 for (unsigned i = 0; i < certs.size(); i++) { 44 for (unsigned i = 0; i < certs.size(); i++) {
42 cert_pieces[i] = StringPiece(certs[i]); 45 cert_pieces[i] = StringPiece(certs[i]);
43 } 46 }
44 scoped_refptr<net::X509Certificate> cert = 47 scoped_refptr<net::X509Certificate> cert =
45 net::X509Certificate::CreateFromDERCertChain(cert_pieces); 48 net::X509Certificate::CreateFromDERCertChain(cert_pieces);
46 if (!cert.get()) { 49 if (!cert.get()) {
47 return net::ERR_FAILED; 50 return FAILURE;
48 } 51 }
49 52
50 common_name_ = cert->subject().GetDisplayName(); 53 common_name_ = cert->subject().GetDisplayName();
51 return net::OK; 54 return SUCCESS;
52 } 55 }
53 56
54 const string& common_name() const { return common_name_; } 57 const string& common_name() const { return common_name_; }
55 58
56 private: 59 private:
57 string common_name_; 60 string common_name_;
58 }; 61 };
59 62
60 } // anonymous namespace 63 } // anonymous namespace
61 64
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 stream_error_ = stream_->stream_error(); 287 stream_error_ = stream_->stream_error();
285 connection_error_ = stream_->connection_error(); 288 connection_error_ = stream_->connection_error();
286 bytes_read_ = stream_->stream_bytes_read(); 289 bytes_read_ = stream_->stream_bytes_read();
287 bytes_written_ = stream_->stream_bytes_written(); 290 bytes_written_ = stream_->stream_bytes_written();
288 stream_ = NULL; 291 stream_ = NULL;
289 } 292 }
290 293
291 } // namespace test 294 } // namespace test
292 } // namespace tools 295 } // namespace tools
293 } // namespace net 296 } // namespace net
OLDNEW
« net/quic/crypto/proof_test.cc ('K') | « net/quic/quic_crypto_client_stream.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698