Chromium Code Reviews| 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/test/spawned_test_server/base_test_server.h" | 5 #include "net/test/spawned_test_server/base_test_server.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/base64.h" | 10 #include "base/base64.h" |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 33 options.server_certificate == | 33 options.server_certificate == |
| 34 BaseTestServer::SSLOptions::CERT_MISMATCHED_NAME) { | 34 BaseTestServer::SSLOptions::CERT_MISMATCHED_NAME) { |
| 35 // Return a different hostname string that resolves to the same hostname. | 35 // Return a different hostname string that resolves to the same hostname. |
| 36 return "localhost"; | 36 return "localhost"; |
| 37 } | 37 } |
| 38 | 38 |
| 39 // Use the 127.0.0.1 as default. | 39 // Use the 127.0.0.1 as default. |
| 40 return BaseTestServer::kLocalhost; | 40 return BaseTestServer::kLocalhost; |
| 41 } | 41 } |
| 42 | 42 |
| 43 void GetKeyExchangesList(int key_exchange, base::ListValue* values) { | |
| 44 if (key_exchange & BaseTestServer::SSLOptions::KEY_EXCHANGE_RSA) | |
| 45 values->Append(new base::StringValue("rsa")); | |
| 46 if (key_exchange & BaseTestServer::SSLOptions::KEY_EXCHANGE_DHE_RSA) | |
| 47 values->Append(new base::StringValue("dhe_rsa")); | |
| 48 } | |
| 49 | |
| 43 void GetCiphersList(int cipher, base::ListValue* values) { | 50 void GetCiphersList(int cipher, base::ListValue* values) { |
| 44 if (cipher & BaseTestServer::SSLOptions::BULK_CIPHER_RC4) | 51 if (cipher & BaseTestServer::SSLOptions::BULK_CIPHER_RC4) |
| 45 values->Append(new base::StringValue("rc4")); | 52 values->Append(new base::StringValue("rc4")); |
| 46 if (cipher & BaseTestServer::SSLOptions::BULK_CIPHER_AES128) | 53 if (cipher & BaseTestServer::SSLOptions::BULK_CIPHER_AES128) |
| 47 values->Append(new base::StringValue("aes128")); | 54 values->Append(new base::StringValue("aes128")); |
| 48 if (cipher & BaseTestServer::SSLOptions::BULK_CIPHER_AES256) | 55 if (cipher & BaseTestServer::SSLOptions::BULK_CIPHER_AES256) |
| 49 values->Append(new base::StringValue("aes256")); | 56 values->Append(new base::StringValue("aes256")); |
| 50 if (cipher & BaseTestServer::SSLOptions::BULK_CIPHER_3DES) | 57 if (cipher & BaseTestServer::SSLOptions::BULK_CIPHER_3DES) |
| 51 values->Append(new base::StringValue("3des")); | 58 values->Append(new base::StringValue("3des")); |
| 52 } | 59 } |
| 53 | 60 |
| 54 } // namespace | 61 } // namespace |
| 55 | 62 |
| 56 BaseTestServer::SSLOptions::SSLOptions() | 63 BaseTestServer::SSLOptions::SSLOptions() |
| 57 : server_certificate(CERT_OK), | 64 : server_certificate(CERT_OK), |
| 58 ocsp_status(OCSP_OK), | 65 ocsp_status(OCSP_OK), |
| 59 cert_serial(0), | 66 cert_serial(0), |
| 60 request_client_certificate(false), | 67 request_client_certificate(false), |
| 68 key_exchanges(SSLOptions::KEY_EXCHANGE_ANY), | |
| 61 bulk_ciphers(SSLOptions::BULK_CIPHER_ANY), | 69 bulk_ciphers(SSLOptions::BULK_CIPHER_ANY), |
| 62 record_resume(false), | 70 record_resume(false), |
| 63 tls_intolerant(TLS_INTOLERANT_NONE), | 71 tls_intolerant(TLS_INTOLERANT_NONE), |
| 64 fallback_scsv_enabled(false), | 72 fallback_scsv_enabled(false), |
| 65 staple_ocsp_response(false) {} | 73 staple_ocsp_response(false), |
| 74 support_npn(false) {} | |
| 66 | 75 |
| 67 BaseTestServer::SSLOptions::SSLOptions( | 76 BaseTestServer::SSLOptions::SSLOptions( |
| 68 BaseTestServer::SSLOptions::ServerCertificate cert) | 77 BaseTestServer::SSLOptions::ServerCertificate cert) |
| 69 : server_certificate(cert), | 78 : server_certificate(cert), |
| 70 ocsp_status(OCSP_OK), | 79 ocsp_status(OCSP_OK), |
| 71 cert_serial(0), | 80 cert_serial(0), |
| 72 request_client_certificate(false), | 81 request_client_certificate(false), |
| 82 key_exchanges(SSLOptions::KEY_EXCHANGE_ANY), | |
| 73 bulk_ciphers(SSLOptions::BULK_CIPHER_ANY), | 83 bulk_ciphers(SSLOptions::BULK_CIPHER_ANY), |
| 74 record_resume(false), | 84 record_resume(false), |
| 75 tls_intolerant(TLS_INTOLERANT_NONE), | 85 tls_intolerant(TLS_INTOLERANT_NONE), |
| 76 fallback_scsv_enabled(false), | 86 fallback_scsv_enabled(false), |
| 77 staple_ocsp_response(false) {} | 87 staple_ocsp_response(false), |
| 88 support_npn(false) {} | |
| 78 | 89 |
| 79 BaseTestServer::SSLOptions::~SSLOptions() {} | 90 BaseTestServer::SSLOptions::~SSLOptions() {} |
| 80 | 91 |
| 81 base::FilePath BaseTestServer::SSLOptions::GetCertificateFile() const { | 92 base::FilePath BaseTestServer::SSLOptions::GetCertificateFile() const { |
| 82 switch (server_certificate) { | 93 switch (server_certificate) { |
| 83 case CERT_OK: | 94 case CERT_OK: |
| 84 case CERT_MISMATCHED_NAME: | 95 case CERT_MISMATCHED_NAME: |
| 85 return base::FilePath(FILE_PATH_LITERAL("ok_cert.pem")); | 96 return base::FilePath(FILE_PATH_LITERAL("ok_cert.pem")); |
| 86 case CERT_EXPIRED: | 97 case CERT_EXPIRED: |
| 87 return base::FilePath(FILE_PATH_LITERAL("expired_cert.pem")); | 98 return base::FilePath(FILE_PATH_LITERAL("expired_cert.pem")); |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 382 | 393 |
| 383 std::string ocsp_arg = ssl_options_.GetOCSPArgument(); | 394 std::string ocsp_arg = ssl_options_.GetOCSPArgument(); |
| 384 if (!ocsp_arg.empty()) | 395 if (!ocsp_arg.empty()) |
| 385 arguments->SetString("ocsp", ocsp_arg); | 396 arguments->SetString("ocsp", ocsp_arg); |
| 386 | 397 |
| 387 if (ssl_options_.cert_serial != 0) { | 398 if (ssl_options_.cert_serial != 0) { |
| 388 arguments->Set("cert-serial", | 399 arguments->Set("cert-serial", |
| 389 base::Value::CreateIntegerValue(ssl_options_.cert_serial)); | 400 base::Value::CreateIntegerValue(ssl_options_.cert_serial)); |
| 390 } | 401 } |
| 391 | 402 |
| 403 // Check key exchange argument. | |
| 404 scoped_ptr<base::ListValue> key_exchange_values(new base::ListValue()); | |
| 405 GetKeyExchangesList(ssl_options_.key_exchanges, key_exchange_values.get()); | |
| 406 if (key_exchange_values->GetSize()) | |
| 407 arguments->Set("ssl-key-exchange", key_exchange_values.release()); | |
| 392 // Check bulk cipher argument. | 408 // Check bulk cipher argument. |
| 393 scoped_ptr<base::ListValue> bulk_cipher_values(new base::ListValue()); | 409 scoped_ptr<base::ListValue> bulk_cipher_values(new base::ListValue()); |
| 394 GetCiphersList(ssl_options_.bulk_ciphers, bulk_cipher_values.get()); | 410 GetCiphersList(ssl_options_.bulk_ciphers, bulk_cipher_values.get()); |
| 395 if (bulk_cipher_values->GetSize()) | 411 if (bulk_cipher_values->GetSize()) |
| 396 arguments->Set("ssl-bulk-cipher", bulk_cipher_values.release()); | 412 arguments->Set("ssl-bulk-cipher", bulk_cipher_values.release()); |
| 397 if (ssl_options_.record_resume) | 413 if (ssl_options_.record_resume) |
| 398 arguments->Set("https-record-resume", base::Value::CreateNullValue()); | 414 arguments->Set("https-record-resume", base::Value::CreateNullValue()); |
| 399 if (ssl_options_.tls_intolerant != SSLOptions::TLS_INTOLERANT_NONE) { | 415 if (ssl_options_.tls_intolerant != SSLOptions::TLS_INTOLERANT_NONE) { |
| 400 arguments->Set("tls-intolerant", | 416 arguments->Set("tls-intolerant", |
| 401 new base::FundamentalValue(ssl_options_.tls_intolerant)); | 417 new base::FundamentalValue(ssl_options_.tls_intolerant)); |
| 402 } | 418 } |
| 403 if (ssl_options_.fallback_scsv_enabled) | 419 if (ssl_options_.fallback_scsv_enabled) |
| 404 arguments->Set("fallback-scsv", base::Value::CreateNullValue()); | 420 arguments->Set("fallback-scsv", base::Value::CreateNullValue()); |
| 405 if (!ssl_options_.signed_cert_timestamps_tls_ext.empty()) { | 421 if (!ssl_options_.signed_cert_timestamps_tls_ext.empty()) { |
| 406 std::string b64_scts_tls_ext; | 422 std::string b64_scts_tls_ext; |
| 407 base::Base64Encode(ssl_options_.signed_cert_timestamps_tls_ext, | 423 base::Base64Encode(ssl_options_.signed_cert_timestamps_tls_ext, |
| 408 &b64_scts_tls_ext); | 424 &b64_scts_tls_ext); |
| 409 arguments->SetString("signed-cert-timestamps-tls-ext", b64_scts_tls_ext); | 425 arguments->SetString("signed-cert-timestamps-tls-ext", b64_scts_tls_ext); |
| 410 } | 426 } |
| 411 if (ssl_options_.staple_ocsp_response) | 427 if (ssl_options_.staple_ocsp_response) |
| 412 arguments->Set("staple-ocsp-response", base::Value::CreateNullValue()); | 428 arguments->Set("staple-ocsp-response", base::Value::CreateNullValue()); |
| 429 if (ssl_options_.support_npn) | |
| 430 arguments->Set("next-proto", base::Value::CreateStringValue("http/1.1")); | |
|
Ryan Sleevi
2014/04/02 22:09:13
Should this be a string option, rather than a bool
davidben
2014/04/03 19:38:36
Well, I suppose if we want to go really crazy, it
| |
| 413 } | 431 } |
| 414 | 432 |
| 415 return GenerateAdditionalArguments(arguments); | 433 return GenerateAdditionalArguments(arguments); |
| 416 } | 434 } |
| 417 | 435 |
| 418 bool BaseTestServer::GenerateAdditionalArguments( | 436 bool BaseTestServer::GenerateAdditionalArguments( |
| 419 base::DictionaryValue* arguments) const { | 437 base::DictionaryValue* arguments) const { |
| 420 return true; | 438 return true; |
| 421 } | 439 } |
| 422 | 440 |
| 423 } // namespace net | 441 } // namespace net |
| OLD | NEW |