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

Side by Side Diff: net/tools/quic/quic_client_bin.cc

Issue 2441053002: Fix seg fault crash of quic_client with --disable-certificate-verification (Closed)
Patch Set: change mail address Created 4 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
« no previous file with comments | « AUTHORS ('k') | net/tools/quic/quic_simple_client_bin.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // A binary wrapper for QuicClient. 5 // A binary wrapper for QuicClient.
6 // Connects to a host using QUIC, sends a request to the provided URL, and 6 // Connects to a host using QUIC, sends a request to the provided URL, and
7 // displays the response. 7 // displays the response.
8 // 8 //
9 // Some usage examples: 9 // Some usage examples:
10 // 10 //
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 #include "net/tools/epoll_server/epoll_server.h" 64 #include "net/tools/epoll_server/epoll_server.h"
65 #include "net/tools/quic/quic_client.h" 65 #include "net/tools/quic/quic_client.h"
66 #include "net/tools/quic/synchronous_host_resolver.h" 66 #include "net/tools/quic/synchronous_host_resolver.h"
67 #include "url/gurl.h" 67 #include "url/gurl.h"
68 68
69 using base::StringPiece; 69 using base::StringPiece;
70 using net::CertVerifier; 70 using net::CertVerifier;
71 using net::CTPolicyEnforcer; 71 using net::CTPolicyEnforcer;
72 using net::CTVerifier; 72 using net::CTVerifier;
73 using net::MultiLogCTVerifier; 73 using net::MultiLogCTVerifier;
74 using net::ProofVerifier;
74 using net::ProofVerifierChromium; 75 using net::ProofVerifierChromium;
75 using net::SpdyHeaderBlock; 76 using net::SpdyHeaderBlock;
76 using net::TransportSecurityState; 77 using net::TransportSecurityState;
77 using std::cout; 78 using std::cout;
78 using std::cerr; 79 using std::cerr;
79 using std::string; 80 using std::string;
80 using std::vector; 81 using std::vector;
81 using std::endl; 82 using std::endl;
82 83
83 // The IP or hostname the quic client will connect to. 84 // The IP or hostname the quic client will connect to.
(...skipping 14 matching lines...) Expand all
98 int32_t FLAGS_quic_version = -1; 99 int32_t FLAGS_quic_version = -1;
99 // If true, a version mismatch in the handshake is not considered a failure. 100 // If true, a version mismatch in the handshake is not considered a failure.
100 // Useful for probing a server to determine if it speaks any version of QUIC. 101 // Useful for probing a server to determine if it speaks any version of QUIC.
101 bool FLAGS_version_mismatch_ok = false; 102 bool FLAGS_version_mismatch_ok = false;
102 // If true, an HTTP response code of 3xx is considered to be a successful 103 // If true, an HTTP response code of 3xx is considered to be a successful
103 // response, otherwise a failure. 104 // response, otherwise a failure.
104 bool FLAGS_redirect_is_success = true; 105 bool FLAGS_redirect_is_success = true;
105 // Initial MTU of the connection. 106 // Initial MTU of the connection.
106 int32_t FLAGS_initial_mtu = 0; 107 int32_t FLAGS_initial_mtu = 0;
107 108
108 class FakeCertVerifier : public net::CertVerifier { 109 class FakeProofVerifier : public ProofVerifier {
109 public: 110 public:
110 int Verify(const RequestParams& params, 111 net::QuicAsyncStatus VerifyProof(
111 net::CRLSet* crl_set, 112 const string& hostname,
112 net::CertVerifyResult* verify_result, 113 const uint16_t port,
113 const net::CompletionCallback& callback, 114 const string& server_config,
114 std::unique_ptr<Request>* out_req, 115 net::QuicVersion quic_version,
115 const net::NetLogWithSource& net_log) override { 116 StringPiece chlo_hash,
116 return net::OK; 117 const vector<string>& certs,
118 const string& cert_sct,
119 const string& signature,
120 const net::ProofVerifyContext* context,
121 string* error_details,
122 std::unique_ptr<net::ProofVerifyDetails>* details,
123 std::unique_ptr<net::ProofVerifierCallback> callback) override {
124 return net::QUIC_SUCCESS;
117 } 125 }
118 126
119 // Returns true if this CertVerifier supports stapled OCSP responses. 127 net::QuicAsyncStatus VerifyCertChain(
120 bool SupportsOCSPStapling() override { return false; } 128 const std::string& hostname,
129 const std::vector<std::string>& certs,
130 const net::ProofVerifyContext* verify_context,
131 std::string* error_details,
132 std::unique_ptr<net::ProofVerifyDetails>* verify_details,
133 std::unique_ptr<net::ProofVerifierCallback> callback) override {
134 return net::QUIC_SUCCESS;
135 }
121 }; 136 };
122 137
123 int main(int argc, char* argv[]) { 138 int main(int argc, char* argv[]) {
124 base::CommandLine::Init(argc, argv); 139 base::CommandLine::Init(argc, argv);
125 base::CommandLine* line = base::CommandLine::ForCurrentProcess(); 140 base::CommandLine* line = base::CommandLine::ForCurrentProcess();
126 const base::CommandLine::StringVector& urls = line->GetArgs(); 141 const base::CommandLine::StringVector& urls = line->GetArgs();
127 142
128 logging::LoggingSettings settings; 143 logging::LoggingSettings settings;
129 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; 144 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
130 CHECK(logging::InitLogging(settings)); 145 CHECK(logging::InitLogging(settings));
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 net::EpollServer epoll_server; 253 net::EpollServer epoll_server;
239 net::QuicServerId server_id(url.host(), url.EffectiveIntPort(), 254 net::QuicServerId server_id(url.host(), url.EffectiveIntPort(),
240 net::PRIVACY_MODE_DISABLED); 255 net::PRIVACY_MODE_DISABLED);
241 net::QuicVersionVector versions = net::AllSupportedVersions(); 256 net::QuicVersionVector versions = net::AllSupportedVersions();
242 if (FLAGS_quic_version != -1) { 257 if (FLAGS_quic_version != -1) {
243 versions.clear(); 258 versions.clear();
244 versions.push_back(static_cast<net::QuicVersion>(FLAGS_quic_version)); 259 versions.push_back(static_cast<net::QuicVersion>(FLAGS_quic_version));
245 } 260 }
246 // For secure QUIC we need to verify the cert chain. 261 // For secure QUIC we need to verify the cert chain.
247 std::unique_ptr<CertVerifier> cert_verifier(CertVerifier::CreateDefault()); 262 std::unique_ptr<CertVerifier> cert_verifier(CertVerifier::CreateDefault());
248 if (line->HasSwitch("disable-certificate-verification")) {
249 cert_verifier.reset(new FakeCertVerifier());
250 }
251 std::unique_ptr<TransportSecurityState> transport_security_state( 263 std::unique_ptr<TransportSecurityState> transport_security_state(
252 new TransportSecurityState); 264 new TransportSecurityState);
253 transport_security_state.reset(new TransportSecurityState); 265 transport_security_state.reset(new TransportSecurityState);
254 std::unique_ptr<CTVerifier> ct_verifier(new MultiLogCTVerifier()); 266 std::unique_ptr<CTVerifier> ct_verifier(new MultiLogCTVerifier());
255 std::unique_ptr<CTPolicyEnforcer> ct_policy_enforcer(new CTPolicyEnforcer()); 267 std::unique_ptr<CTPolicyEnforcer> ct_policy_enforcer(new CTPolicyEnforcer());
256 std::unique_ptr<net::ProofVerifierChromium> proof_verifier( 268 std::unique_ptr<ProofVerifier> proof_verifier;
257 new ProofVerifierChromium(cert_verifier.get(), ct_policy_enforcer.get(), 269 if (line->HasSwitch("disable-certificate-verification")) {
258 transport_security_state.get(), 270 proof_verifier.reset(new FakeProofVerifier());
259 ct_verifier.get())); 271 } else {
272 proof_verifier.reset(new ProofVerifierChromium(
273 cert_verifier.get(), ct_policy_enforcer.get(),
274 transport_security_state.get(), ct_verifier.get()));
275 }
260 net::QuicClient client(net::IPEndPoint(ip_addr, port), server_id, versions, 276 net::QuicClient client(net::IPEndPoint(ip_addr, port), server_id, versions,
261 &epoll_server, std::move(proof_verifier)); 277 &epoll_server, std::move(proof_verifier));
262 client.set_initial_max_packet_length( 278 client.set_initial_max_packet_length(
263 FLAGS_initial_mtu != 0 ? FLAGS_initial_mtu : net::kDefaultMaxPacketSize); 279 FLAGS_initial_mtu != 0 ? FLAGS_initial_mtu : net::kDefaultMaxPacketSize);
264 if (!client.Initialize()) { 280 if (!client.Initialize()) {
265 cerr << "Failed to initialize client." << endl; 281 cerr << "Failed to initialize client." << endl;
266 return 1; 282 return 1;
267 } 283 }
268 if (!client.Connect()) { 284 if (!client.Connect()) {
269 net::QuicErrorCode error = client.session()->error(); 285 net::QuicErrorCode error = client.session()->error();
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 return 0; 368 return 0;
353 } else { 369 } else {
354 cout << "Request failed (redirect " << response_code << ")." << endl; 370 cout << "Request failed (redirect " << response_code << ")." << endl;
355 return 1; 371 return 1;
356 } 372 }
357 } else { 373 } else {
358 cerr << "Request failed (" << response_code << ")." << endl; 374 cerr << "Request failed (" << response_code << ")." << endl;
359 return 1; 375 return 1;
360 } 376 }
361 } 377 }
OLDNEW
« no previous file with comments | « AUTHORS ('k') | net/tools/quic/quic_simple_client_bin.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698