Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Unified Diff: net/tools/testserver/testserver.py

Issue 11175002: testserver.py TLS and client auth support on WebSocket. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix indent Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/test/base_test_server.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/tools/testserver/testserver.py
diff --git a/net/tools/testserver/testserver.py b/net/tools/testserver/testserver.py
index 1cae65d226624f2de1d2d84f96feb35afa860013..b78aa76e0fb3c3e6b9e5860008d929517336f326 100755
--- a/net/tools/testserver/testserver.py
+++ b/net/tools/testserver/testserver.py
@@ -93,10 +93,10 @@ class WebSocketOptions:
self.allow_draft75 = False
self.strict = True
- # TODO(toyoshim): Support SSL and authenticates (http://crbug.com/137639)
self.use_tls = False
self.private_key = None
self.certificate = None
+ self.tls_client_auth = False
self.tls_client_ca = None
self.use_basic_auth = False
@@ -2235,8 +2235,8 @@ def main(options, args):
for ca_cert in options.ssl_client_ca:
if not os.path.isfile(ca_cert):
- print 'specified trusted client CA file not found: ' + ca_cert + \
- ' exiting...'
+ print ('specified trusted client CA file not found: ' + ca_cert +
+ ' exiting...')
return
server = HTTPSServer((host, port), TestPageHandler, pem_cert_and_key,
options.ssl_client_auth, options.ssl_client_ca,
@@ -2261,7 +2261,24 @@ def main(options, args):
# TODO(toyoshim): Remove following os.chdir. Currently this operation
# is required to work correctly. It should be fixed from pywebsocket side.
os.chdir(MakeDataDir())
- server = WebSocketServer(WebSocketOptions(host, port, '.'))
+ websocket_options = WebSocketOptions(host, port, '.')
+ if options.cert_and_key_file:
+ websocket_options.use_tls = True
+ websocket_options.private_key = options.cert_and_key_file
+ websocket_options.certificate = options.cert_and_key_file
+ if options.ssl_client_auth:
+ websocket_options.tls_client_auth = True
+ if len(options.ssl_client_ca) != 1:
+ # TODO(phajdan.jr): Provide non-zero exit code for these error cases.
Paweł Hajdan Jr. 2012/10/17 16:59:11 Sorry for ambiguity, I intended that to be a TODO
+ # Ditto on other paths here and there.
+ print 'one trusted client CA file should be specified'
+ return
+ if not os.path.isfile(options.ssl_client_ca[0]):
+ print ('specified trusted client CA file not found: ' +
+ options.ssl_client_ca[0] + ' exiting...')
+ return
+ websocket_options.tls_client_ca = options.ssl_client_ca[0]
+ server = WebSocketServer(websocket_options)
print 'WebSocket server started on %s:%d...' % (host, server.server_port)
server_data['port'] = server.server_port
elif options.server_type == SERVER_SYNC:
« no previous file with comments | « net/test/base_test_server.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698