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

Side by Side Diff: net/tools/testserver/testserver.py

Issue 981723008: Unwind the SSL connection holdback experiment and remove related code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename & reformat Created 5 years, 9 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 unified diff | Download patch
« no previous file with comments | « net/test/spawned_test_server/base_test_server.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2013 The Chromium Authors. All rights reserved. 2 # Copyright 2013 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """This is a simple HTTP/FTP/TCP/UDP/BASIC_AUTH_PROXY/WEBSOCKET server used for 6 """This is a simple HTTP/FTP/TCP/UDP/BASIC_AUTH_PROXY/WEBSOCKET server used for
7 testing Chrome. 7 testing Chrome.
8 8
9 It supports several test URLs, as specified by the handlers in TestPageHandler. 9 It supports several test URLs, as specified by the handlers in TestPageHandler.
10 By default, it listens on an ephemeral port and sends the port number back to 10 By default, it listens on an ephemeral port and sends the port number back to
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 testserver_base.BrokenPipeHandlerMixIn, 150 testserver_base.BrokenPipeHandlerMixIn,
151 testserver_base.StoppableHTTPServer): 151 testserver_base.StoppableHTTPServer):
152 """This is a specialization of StoppableHTTPServer that add https support and 152 """This is a specialization of StoppableHTTPServer that add https support and
153 client verification.""" 153 client verification."""
154 154
155 def __init__(self, server_address, request_hander_class, pem_cert_and_key, 155 def __init__(self, server_address, request_hander_class, pem_cert_and_key,
156 ssl_client_auth, ssl_client_cas, ssl_client_cert_types, 156 ssl_client_auth, ssl_client_cas, ssl_client_cert_types,
157 ssl_bulk_ciphers, ssl_key_exchanges, enable_npn, 157 ssl_bulk_ciphers, ssl_key_exchanges, enable_npn,
158 record_resume_info, tls_intolerant, 158 record_resume_info, tls_intolerant,
159 tls_intolerance_type, signed_cert_timestamps, 159 tls_intolerance_type, signed_cert_timestamps,
160 fallback_scsv_enabled, ocsp_response, disable_session_cache): 160 fallback_scsv_enabled, ocsp_response):
161 self.cert_chain = tlslite.api.X509CertChain() 161 self.cert_chain = tlslite.api.X509CertChain()
162 self.cert_chain.parsePemList(pem_cert_and_key) 162 self.cert_chain.parsePemList(pem_cert_and_key)
163 # Force using only python implementation - otherwise behavior is different 163 # Force using only python implementation - otherwise behavior is different
164 # depending on whether m2crypto Python module is present (error is thrown 164 # depending on whether m2crypto Python module is present (error is thrown
165 # when it is). m2crypto uses a C (based on OpenSSL) implementation under 165 # when it is). m2crypto uses a C (based on OpenSSL) implementation under
166 # the hood. 166 # the hood.
167 self.private_key = tlslite.api.parsePEMKey(pem_cert_and_key, 167 self.private_key = tlslite.api.parsePEMKey(pem_cert_and_key,
168 private=True, 168 private=True,
169 implementations=['python']) 169 implementations=['python'])
170 self.ssl_client_auth = ssl_client_auth 170 self.ssl_client_auth = ssl_client_auth
(...skipping 25 matching lines...) Expand all
196 # Enable SSLv3 for testing purposes. 196 # Enable SSLv3 for testing purposes.
197 self.ssl_handshake_settings.minVersion = (3, 0) 197 self.ssl_handshake_settings.minVersion = (3, 0)
198 if ssl_bulk_ciphers is not None: 198 if ssl_bulk_ciphers is not None:
199 self.ssl_handshake_settings.cipherNames = ssl_bulk_ciphers 199 self.ssl_handshake_settings.cipherNames = ssl_bulk_ciphers
200 if ssl_key_exchanges is not None: 200 if ssl_key_exchanges is not None:
201 self.ssl_handshake_settings.keyExchangeNames = ssl_key_exchanges 201 self.ssl_handshake_settings.keyExchangeNames = ssl_key_exchanges
202 if tls_intolerant != 0: 202 if tls_intolerant != 0:
203 self.ssl_handshake_settings.tlsIntolerant = (3, tls_intolerant) 203 self.ssl_handshake_settings.tlsIntolerant = (3, tls_intolerant)
204 self.ssl_handshake_settings.tlsIntoleranceType = tls_intolerance_type 204 self.ssl_handshake_settings.tlsIntoleranceType = tls_intolerance_type
205 205
206 206 if record_resume_info:
207 if disable_session_cache:
208 self.session_cache = None
209 elif record_resume_info:
210 # If record_resume_info is true then we'll replace the session cache with 207 # If record_resume_info is true then we'll replace the session cache with
211 # an object that records the lookups and inserts that it sees. 208 # an object that records the lookups and inserts that it sees.
212 self.session_cache = RecordingSSLSessionCache() 209 self.session_cache = RecordingSSLSessionCache()
213 else: 210 else:
214 self.session_cache = tlslite.api.SessionCache() 211 self.session_cache = tlslite.api.SessionCache()
215 testserver_base.StoppableHTTPServer.__init__(self, 212 testserver_base.StoppableHTTPServer.__init__(self,
216 server_address, 213 server_address,
217 request_hander_class) 214 request_hander_class)
218 215
219 def handshake(self, tlsConnection): 216 def handshake(self, tlsConnection):
(...skipping 1821 matching lines...) Expand 10 before | Expand all | Expand 10 after
2041 self.options.ssl_client_cert_type, 2038 self.options.ssl_client_cert_type,
2042 self.options.ssl_bulk_cipher, 2039 self.options.ssl_bulk_cipher,
2043 self.options.ssl_key_exchange, 2040 self.options.ssl_key_exchange,
2044 self.options.enable_npn, 2041 self.options.enable_npn,
2045 self.options.record_resume, 2042 self.options.record_resume,
2046 self.options.tls_intolerant, 2043 self.options.tls_intolerant,
2047 self.options.tls_intolerance_type, 2044 self.options.tls_intolerance_type,
2048 self.options.signed_cert_timestamps_tls_ext.decode( 2045 self.options.signed_cert_timestamps_tls_ext.decode(
2049 "base64"), 2046 "base64"),
2050 self.options.fallback_scsv, 2047 self.options.fallback_scsv,
2051 stapled_ocsp_response, 2048 stapled_ocsp_response)
2052 self.options.disable_session_cache)
2053 print 'HTTPS server started on https://%s:%d...' % \ 2049 print 'HTTPS server started on https://%s:%d...' % \
2054 (host, server.server_port) 2050 (host, server.server_port)
2055 else: 2051 else:
2056 server = HTTPServer((host, port), TestPageHandler) 2052 server = HTTPServer((host, port), TestPageHandler)
2057 print 'HTTP server started on http://%s:%d...' % \ 2053 print 'HTTP server started on http://%s:%d...' % \
2058 (host, server.server_port) 2054 (host, server.server_port)
2059 2055
2060 server.data_dir = self.__make_data_dir() 2056 server.data_dir = self.__make_data_dir()
2061 server.file_root_url = self.options.file_root_url 2057 server.file_root_url = self.options.file_root_url
2062 server_data['port'] = server.server_port 2058 server_data['port'] = server.server_port
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
2142 if self.__ocsp_server: 2138 if self.__ocsp_server:
2143 self.__ocsp_server.serve_forever_on_thread() 2139 self.__ocsp_server.serve_forever_on_thread()
2144 2140
2145 testserver_base.TestServerRunner.run_server(self) 2141 testserver_base.TestServerRunner.run_server(self)
2146 2142
2147 if self.__ocsp_server: 2143 if self.__ocsp_server:
2148 self.__ocsp_server.stop_serving() 2144 self.__ocsp_server.stop_serving()
2149 2145
2150 def add_options(self): 2146 def add_options(self):
2151 testserver_base.TestServerRunner.add_options(self) 2147 testserver_base.TestServerRunner.add_options(self)
2152 self.option_parser.add_option('--disable-session-cache',
2153 action='store_true',
2154 dest='disable_session_cache',
2155 help='tells the server to disable the'
2156 'TLS session cache.')
2157 self.option_parser.add_option('-f', '--ftp', action='store_const', 2148 self.option_parser.add_option('-f', '--ftp', action='store_const',
2158 const=SERVER_FTP, default=SERVER_HTTP, 2149 const=SERVER_FTP, default=SERVER_HTTP,
2159 dest='server_type', 2150 dest='server_type',
2160 help='start up an FTP server.') 2151 help='start up an FTP server.')
2161 self.option_parser.add_option('--tcp-echo', action='store_const', 2152 self.option_parser.add_option('--tcp-echo', action='store_const',
2162 const=SERVER_TCP_ECHO, default=SERVER_HTTP, 2153 const=SERVER_TCP_ECHO, default=SERVER_HTTP,
2163 dest='server_type', 2154 dest='server_type',
2164 help='start up a tcp echo server.') 2155 help='start up a tcp echo server.')
2165 self.option_parser.add_option('--udp-echo', action='store_const', 2156 self.option_parser.add_option('--udp-echo', action='store_const',
2166 const=SERVER_UDP_ECHO, default=SERVER_HTTP, 2157 const=SERVER_UDP_ECHO, default=SERVER_HTTP,
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
2284 self.option_parser.add_option('--ocsp-server-unavailable', 2275 self.option_parser.add_option('--ocsp-server-unavailable',
2285 dest='ocsp_server_unavailable', 2276 dest='ocsp_server_unavailable',
2286 default=False, action='store_true', 2277 default=False, action='store_true',
2287 help='If set, the OCSP server will return ' 2278 help='If set, the OCSP server will return '
2288 'a tryLater status rather than the actual ' 2279 'a tryLater status rather than the actual '
2289 'OCSP response.') 2280 'OCSP response.')
2290 2281
2291 2282
2292 if __name__ == '__main__': 2283 if __name__ == '__main__':
2293 sys.exit(ServerRunner().main()) 2284 sys.exit(ServerRunner().main())
OLDNEW
« no previous file with comments | « net/test/spawned_test_server/base_test_server.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698