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 11 matching lines...) Expand all Loading... |
22 #include "net/dns/host_resolver.h" | 22 #include "net/dns/host_resolver.h" |
23 #include "net/log/net_log.h" | 23 #include "net/log/net_log.h" |
24 #include "url/gurl.h" | 24 #include "url/gurl.h" |
25 | 25 |
26 namespace net { | 26 namespace net { |
27 | 27 |
28 namespace { | 28 namespace { |
29 | 29 |
30 std::string GetHostname(BaseTestServer::Type type, | 30 std::string GetHostname(BaseTestServer::Type type, |
31 const BaseTestServer::SSLOptions& options) { | 31 const BaseTestServer::SSLOptions& options) { |
32 if (BaseTestServer::UsingSSL(type) && | 32 if (BaseTestServer::UsingSSL(type)) { |
33 options.server_certificate == | 33 if (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 options.server_certificate == |
36 return "localhost"; | 36 BaseTestServer::SSLOptions::CERT_COMMON_NAME_IS_DOMAIN) { |
| 37 // For |CERT_MISMATCHED_NAME|, return a different hostname string |
| 38 // that resolves to the same hostname. For |
| 39 // |CERT_COMMON_NAME_IS_DOMAIN|, the certificate is issued for |
| 40 // "localhost" instead of "127.0.0.1". |
| 41 return "localhost"; |
| 42 } |
37 } | 43 } |
38 | 44 |
39 // Use the 127.0.0.1 as default. | 45 // Use the 127.0.0.1 as default. |
40 return BaseTestServer::kLocalhost; | 46 return BaseTestServer::kLocalhost; |
41 } | 47 } |
42 | 48 |
43 std::string GetClientCertType(SSLClientCertType type) { | 49 std::string GetClientCertType(SSLClientCertType type) { |
44 switch (type) { | 50 switch (type) { |
45 case CLIENT_CERT_RSA_SIGN: | 51 case CLIENT_CERT_RSA_SIGN: |
46 return "rsa_sign"; | 52 return "rsa_sign"; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 alert_after_handshake(false) { | 134 alert_after_handshake(false) { |
129 } | 135 } |
130 | 136 |
131 BaseTestServer::SSLOptions::~SSLOptions() {} | 137 BaseTestServer::SSLOptions::~SSLOptions() {} |
132 | 138 |
133 base::FilePath BaseTestServer::SSLOptions::GetCertificateFile() const { | 139 base::FilePath BaseTestServer::SSLOptions::GetCertificateFile() const { |
134 switch (server_certificate) { | 140 switch (server_certificate) { |
135 case CERT_OK: | 141 case CERT_OK: |
136 case CERT_MISMATCHED_NAME: | 142 case CERT_MISMATCHED_NAME: |
137 return base::FilePath(FILE_PATH_LITERAL("ok_cert.pem")); | 143 return base::FilePath(FILE_PATH_LITERAL("ok_cert.pem")); |
| 144 case CERT_COMMON_NAME_IS_DOMAIN: |
| 145 return base::FilePath(FILE_PATH_LITERAL("localhost_cert.pem")); |
138 case CERT_EXPIRED: | 146 case CERT_EXPIRED: |
139 return base::FilePath(FILE_PATH_LITERAL("expired_cert.pem")); | 147 return base::FilePath(FILE_PATH_LITERAL("expired_cert.pem")); |
140 case CERT_CHAIN_WRONG_ROOT: | 148 case CERT_CHAIN_WRONG_ROOT: |
141 // This chain uses its own dedicated test root certificate to avoid | 149 // This chain uses its own dedicated test root certificate to avoid |
142 // side-effects that may affect testing. | 150 // side-effects that may affect testing. |
143 return base::FilePath(FILE_PATH_LITERAL("redundant-server-chain.pem")); | 151 return base::FilePath(FILE_PATH_LITERAL("redundant-server-chain.pem")); |
144 case CERT_AUTO: | 152 case CERT_AUTO: |
145 return base::FilePath(); | 153 return base::FilePath(); |
146 default: | 154 default: |
147 NOTREACHED(); | 155 NOTREACHED(); |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 | 502 |
495 return GenerateAdditionalArguments(arguments); | 503 return GenerateAdditionalArguments(arguments); |
496 } | 504 } |
497 | 505 |
498 bool BaseTestServer::GenerateAdditionalArguments( | 506 bool BaseTestServer::GenerateAdditionalArguments( |
499 base::DictionaryValue* arguments) const { | 507 base::DictionaryValue* arguments) const { |
500 return true; | 508 return true; |
501 } | 509 } |
502 | 510 |
503 } // namespace net | 511 } // namespace net |
OLD | NEW |