OLD | NEW |
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 Loading... |
64 #include "net/spdy/spdy_http_utils.h" | 64 #include "net/spdy/spdy_http_utils.h" |
65 #include "net/tools/quic/quic_simple_client.h" | 65 #include "net/tools/quic/quic_simple_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::TransportSecurityState; | 76 using net::TransportSecurityState; |
76 using std::cout; | 77 using std::cout; |
77 using std::cerr; | 78 using std::cerr; |
78 using std::map; | 79 using std::map; |
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 Loading... |
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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 // Build the client, and try to connect. | 254 // Build the client, and try to connect. |
240 net::QuicServerId server_id(url.host(), url.EffectiveIntPort(), | 255 net::QuicServerId server_id(url.host(), url.EffectiveIntPort(), |
241 net::PRIVACY_MODE_DISABLED); | 256 net::PRIVACY_MODE_DISABLED); |
242 net::QuicVersionVector versions = net::AllSupportedVersions(); | 257 net::QuicVersionVector versions = net::AllSupportedVersions(); |
243 if (FLAGS_quic_version != -1) { | 258 if (FLAGS_quic_version != -1) { |
244 versions.clear(); | 259 versions.clear(); |
245 versions.push_back(static_cast<net::QuicVersion>(FLAGS_quic_version)); | 260 versions.push_back(static_cast<net::QuicVersion>(FLAGS_quic_version)); |
246 } | 261 } |
247 // For secure QUIC we need to verify the cert chain. | 262 // For secure QUIC we need to verify the cert chain. |
248 std::unique_ptr<CertVerifier> cert_verifier(CertVerifier::CreateDefault()); | 263 std::unique_ptr<CertVerifier> cert_verifier(CertVerifier::CreateDefault()); |
249 if (line->HasSwitch("disable-certificate-verification")) { | |
250 cert_verifier.reset(new FakeCertVerifier()); | |
251 } | |
252 std::unique_ptr<TransportSecurityState> transport_security_state( | 264 std::unique_ptr<TransportSecurityState> transport_security_state( |
253 new TransportSecurityState); | 265 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<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::QuicSimpleClient client(net::IPEndPoint(ip_addr, port), server_id, | 276 net::QuicSimpleClient client(net::IPEndPoint(ip_addr, port), server_id, |
261 versions, std::move(proof_verifier)); | 277 versions, 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 return 0; | 369 return 0; |
354 } else { | 370 } else { |
355 cout << "Request failed (redirect " << response_code << ")." << endl; | 371 cout << "Request failed (redirect " << response_code << ")." << endl; |
356 return 1; | 372 return 1; |
357 } | 373 } |
358 } else { | 374 } else { |
359 cerr << "Request failed (" << response_code << ")." << endl; | 375 cerr << "Request failed (" << response_code << ")." << endl; |
360 return 1; | 376 return 1; |
361 } | 377 } |
362 } | 378 } |
OLD | NEW |