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

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

Issue 1437023002: Landing Recent QUIC changes until 2015-11-09 20:32 UTC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
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 "base/time/time.h" 7 #include "base/time/time.h"
8 #include "net/base/completion_callback.h" 8 #include "net/base/completion_callback.h"
9 #include "net/base/net_errors.h" 9 #include "net/base/net_errors.h"
10 #include "net/cert/cert_verify_result.h" 10 #include "net/cert/cert_verify_result.h"
(...skipping 28 matching lines...) Expand all
39 namespace { 39 namespace {
40 40
41 // RecordingProofVerifier accepts any certificate chain and records the common 41 // RecordingProofVerifier accepts any certificate chain and records the common
42 // name of the leaf. 42 // name of the leaf.
43 class RecordingProofVerifier : public ProofVerifier { 43 class RecordingProofVerifier : public ProofVerifier {
44 public: 44 public:
45 // ProofVerifier interface. 45 // ProofVerifier interface.
46 QuicAsyncStatus VerifyProof(const string& hostname, 46 QuicAsyncStatus VerifyProof(const string& hostname,
47 const string& server_config, 47 const string& server_config,
48 const vector<string>& certs, 48 const vector<string>& certs,
49 const string& cert_sct,
49 const string& signature, 50 const string& signature,
50 const ProofVerifyContext* context, 51 const ProofVerifyContext* context,
51 string* error_details, 52 string* error_details,
52 scoped_ptr<ProofVerifyDetails>* details, 53 scoped_ptr<ProofVerifyDetails>* details,
53 ProofVerifierCallback* callback) override { 54 ProofVerifierCallback* callback) override {
54 common_name_.clear(); 55 common_name_.clear();
55 if (certs.empty()) { 56 if (certs.empty()) {
56 return QUIC_FAILURE; 57 return QUIC_FAILURE;
57 } 58 }
58 59
59 // Convert certs to X509Certificate. 60 // Convert certs to X509Certificate.
60 vector<StringPiece> cert_pieces(certs.size()); 61 vector<StringPiece> cert_pieces(certs.size());
61 for (unsigned i = 0; i < certs.size(); i++) { 62 for (unsigned i = 0; i < certs.size(); i++) {
62 cert_pieces[i] = StringPiece(certs[i]); 63 cert_pieces[i] = StringPiece(certs[i]);
63 } 64 }
64 // TODO(rtenneti): Fix after adding support for real certs. Currently, 65 // TODO(rtenneti): Fix after adding support for real certs. Currently,
65 // cert_pieces are "leaf" and "intermediate" and CreateFromDERCertChain 66 // cert_pieces are "leaf" and "intermediate" and CreateFromDERCertChain
66 // fails to return cert from these cert_pieces. 67 // fails to return cert from these cert_pieces.
67 // scoped_refptr<net::X509Certificate> cert = 68 // scoped_refptr<net::X509Certificate> cert =
68 // net::X509Certificate::CreateFromDERCertChain(cert_pieces); 69 // net::X509Certificate::CreateFromDERCertChain(cert_pieces);
69 // if (!cert.get()) { 70 // if (!cert.get()) {
70 // return QUIC_FAILURE; 71 // return QUIC_FAILURE;
71 // } 72 // }
72 // 73 //
73 // common_name_ = cert->subject().GetDisplayName(); 74 // common_name_ = cert->subject().GetDisplayName();
75 cert_sct_ = cert_sct;
76
74 return QUIC_SUCCESS; 77 return QUIC_SUCCESS;
75 } 78 }
76 79
77 const string& common_name() const { return common_name_; } 80 const string& common_name() const { return common_name_; }
78 81
82 const string& cert_sct() const { return cert_sct_; }
83
79 private: 84 private:
80 string common_name_; 85 string common_name_;
86 string cert_sct_;
81 }; 87 };
82 88
83 } // anonymous namespace 89 } // anonymous namespace
84 90
85 BalsaHeaders* MungeHeaders(const BalsaHeaders* const_headers) { 91 BalsaHeaders* MungeHeaders(const BalsaHeaders* const_headers) {
86 StringPiece uri = const_headers->request_uri(); 92 StringPiece uri = const_headers->request_uri();
87 if (uri.empty()) { 93 if (uri.empty()) {
88 return nullptr; 94 return nullptr;
89 } 95 }
90 if (const_headers->request_method() == "CONNECT") { 96 if (const_headers->request_method() == "CONNECT") {
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 return client()->connection_error(); 386 return client()->connection_error();
381 } 387 }
382 388
383 MockableQuicClient* QuicTestClient::client() { return client_.get(); } 389 MockableQuicClient* QuicTestClient::client() { return client_.get(); }
384 390
385 const string& QuicTestClient::cert_common_name() const { 391 const string& QuicTestClient::cert_common_name() const {
386 return reinterpret_cast<RecordingProofVerifier*>(client_->proof_verifier()) 392 return reinterpret_cast<RecordingProofVerifier*>(client_->proof_verifier())
387 ->common_name(); 393 ->common_name();
388 } 394 }
389 395
396 const string& QuicTestClient::cert_sct() const {
397 return reinterpret_cast<RecordingProofVerifier*>(client_->proof_verifier())
398 ->cert_sct();
399 }
400
390 QuicTagValueMap QuicTestClient::GetServerConfig() const { 401 QuicTagValueMap QuicTestClient::GetServerConfig() const {
391 QuicCryptoClientConfig* config = client_->crypto_config(); 402 QuicCryptoClientConfig* config = client_->crypto_config();
392 QuicCryptoClientConfig::CachedState* state = 403 QuicCryptoClientConfig::CachedState* state =
393 config->LookupOrCreate(client_->server_id()); 404 config->LookupOrCreate(client_->server_id());
394 const CryptoHandshakeMessage* handshake_msg = state->GetServerConfig(); 405 const CryptoHandshakeMessage* handshake_msg = state->GetServerConfig();
395 if (handshake_msg != nullptr) { 406 if (handshake_msg != nullptr) {
396 return handshake_msg->tag_value_map(); 407 return handshake_msg->tag_value_map();
397 } else { 408 } else {
398 return QuicTagValueMap(); 409 return QuicTagValueMap();
399 } 410 }
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 message->headers()->SetRequestVersion( 626 message->headers()->SetRequestVersion(
616 HTTPMessage::VersionToString(HttpConstants::HTTP_1_1)); 627 HTTPMessage::VersionToString(HttpConstants::HTTP_1_1));
617 message->headers()->SetRequestMethod( 628 message->headers()->SetRequestMethod(
618 HTTPMessage::MethodToString(HttpConstants::GET)); 629 HTTPMessage::MethodToString(HttpConstants::GET));
619 message->headers()->SetRequestUri(uri); 630 message->headers()->SetRequestUri(uri);
620 } 631 }
621 632
622 } // namespace test 633 } // namespace test
623 } // namespace tools 634 } // namespace tools
624 } // namespace net 635 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/test_tools/quic_test_client.h ('k') | net/tools/quic/test_tools/quic_test_server.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698