summaryrefslogtreecommitdiffstats
path: root/net/test/test_server.h
diff options
context:
space:
mode:
Diffstat (limited to 'net/test/test_server.h')
-rw-r--r--net/test/test_server.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/net/test/test_server.h b/net/test/test_server.h
index 3b21339..989e38d 100644
--- a/net/test/test_server.h
+++ b/net/test/test_server.h
@@ -76,6 +76,13 @@ class TestServerLauncher {
FilePath GetDocumentRootPath() { return document_root_dir_; }
+ // When Start is called, if protocol is HTTPS and ssl_client_auth_ is true,
+ // the server will request a client certificate on each connection. Must be
+ // called before Start to take effect.
+ void set_ssl_client_auth(bool ssl_client_auth) {
+ ssl_client_auth_ = ssl_client_auth;
+ }
+
// Issuer name of the root cert that should be trusted for the test to work.
static const wchar_t kCertIssuerName[];
@@ -123,6 +130,8 @@ class TestServerLauncher {
scoped_refptr<X509Certificate> cert_;
#endif
+ bool ssl_client_auth_;
+
DISALLOW_COPY_AND_ASSIGN(TestServerLauncher);
};
@@ -262,6 +271,22 @@ class HTTPSTestServer : public HTTPTestServer {
return test_server;
}
+ // Create a server which requests SSL client auth
+ static scoped_refptr<HTTPSTestServer> CreateClientAuthServer(
+ const std::wstring& document_root) {
+ scoped_refptr<HTTPSTestServer> test_server = new HTTPSTestServer();
+ FilePath docroot = FilePath::FromWStringHack(document_root);
+ FilePath certpath = test_server->launcher_.GetOKCertPath();
+ test_server->launcher_.set_ssl_client_auth(true);
+ if (!test_server->Start(net::TestServerLauncher::ProtoHTTP,
+ net::TestServerLauncher::kHostName,
+ net::TestServerLauncher::kOKHTTPSPort,
+ docroot, certpath, std::wstring())) {
+ return NULL;
+ }
+ return test_server;
+ }
+
// Create a server with an up to date certificate for the wrong hostname
// for this host
static scoped_refptr<HTTPSTestServer> CreateMismatchedServer(