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 std::string GetClientCertType(SSLClientCertType type) { |
| 44 switch (type) { |
| 45 case CLIENT_CERT_RSA_SIGN: |
| 46 return "rsa_sign"; |
| 47 case CLIENT_CERT_DSS_SIGN: |
| 48 return "dss_sign"; |
| 49 case CLIENT_CERT_ECDSA_SIGN: |
| 50 return "ecdsa_sign"; |
| 51 default: |
| 52 NOTREACHED(); |
| 53 return ""; |
| 54 } |
| 55 } |
| 56 |
43 void GetKeyExchangesList(int key_exchange, base::ListValue* values) { | 57 void GetKeyExchangesList(int key_exchange, base::ListValue* values) { |
44 if (key_exchange & BaseTestServer::SSLOptions::KEY_EXCHANGE_RSA) | 58 if (key_exchange & BaseTestServer::SSLOptions::KEY_EXCHANGE_RSA) |
45 values->Append(new base::StringValue("rsa")); | 59 values->Append(new base::StringValue("rsa")); |
46 if (key_exchange & BaseTestServer::SSLOptions::KEY_EXCHANGE_DHE_RSA) | 60 if (key_exchange & BaseTestServer::SSLOptions::KEY_EXCHANGE_DHE_RSA) |
47 values->Append(new base::StringValue("dhe_rsa")); | 61 values->Append(new base::StringValue("dhe_rsa")); |
48 } | 62 } |
49 | 63 |
50 void GetCiphersList(int cipher, base::ListValue* values) { | 64 void GetCiphersList(int cipher, base::ListValue* values) { |
51 if (cipher & BaseTestServer::SSLOptions::BULK_CIPHER_RC4) | 65 if (cipher & BaseTestServer::SSLOptions::BULK_CIPHER_RC4) |
52 values->Append(new base::StringValue("rc4")); | 66 values->Append(new base::StringValue("rc4")); |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 if (it->IsAbsolute() && !base::PathExists(*it)) { | 393 if (it->IsAbsolute() && !base::PathExists(*it)) { |
380 LOG(ERROR) << "Client authority path " << it->value() | 394 LOG(ERROR) << "Client authority path " << it->value() |
381 << " doesn't exist. Can't launch https server."; | 395 << " doesn't exist. Can't launch https server."; |
382 return false; | 396 return false; |
383 } | 397 } |
384 ssl_client_certs->Append(new base::StringValue(it->value())); | 398 ssl_client_certs->Append(new base::StringValue(it->value())); |
385 } | 399 } |
386 | 400 |
387 if (ssl_client_certs->GetSize()) | 401 if (ssl_client_certs->GetSize()) |
388 arguments->Set("ssl-client-ca", ssl_client_certs.release()); | 402 arguments->Set("ssl-client-ca", ssl_client_certs.release()); |
| 403 |
| 404 scoped_ptr<base::ListValue> client_cert_types(new base::ListValue()); |
| 405 for (size_t i = 0; i < ssl_options_.client_cert_types.size(); i++) { |
| 406 client_cert_types->Append(new base::StringValue( |
| 407 GetClientCertType(ssl_options_.client_cert_types[i]))); |
| 408 } |
| 409 if (client_cert_types->GetSize()) |
| 410 arguments->Set("ssl-client-cert-type", client_cert_types.release()); |
389 } | 411 } |
390 | 412 |
391 if (type_ == TYPE_HTTPS) { | 413 if (type_ == TYPE_HTTPS) { |
392 arguments->Set("https", base::Value::CreateNullValue()); | 414 arguments->Set("https", base::Value::CreateNullValue()); |
393 | 415 |
394 std::string ocsp_arg = ssl_options_.GetOCSPArgument(); | 416 std::string ocsp_arg = ssl_options_.GetOCSPArgument(); |
395 if (!ocsp_arg.empty()) | 417 if (!ocsp_arg.empty()) |
396 arguments->SetString("ocsp", ocsp_arg); | 418 arguments->SetString("ocsp", ocsp_arg); |
397 | 419 |
398 if (ssl_options_.cert_serial != 0) { | 420 if (ssl_options_.cert_serial != 0) { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 | 454 |
433 return GenerateAdditionalArguments(arguments); | 455 return GenerateAdditionalArguments(arguments); |
434 } | 456 } |
435 | 457 |
436 bool BaseTestServer::GenerateAdditionalArguments( | 458 bool BaseTestServer::GenerateAdditionalArguments( |
437 base::DictionaryValue* arguments) const { | 459 base::DictionaryValue* arguments) const { |
438 return true; | 460 return true; |
439 } | 461 } |
440 | 462 |
441 } // namespace net | 463 } // namespace net |
OLD | NEW |