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

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

Issue 208293002: Add False Start tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add negative tests Created 6 years, 8 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 | Annotate | Revision Log
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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 143
144 class HTTPSServer(tlslite.api.TLSSocketServerMixIn, 144 class HTTPSServer(tlslite.api.TLSSocketServerMixIn,
145 testserver_base.ClientRestrictingServerMixIn, 145 testserver_base.ClientRestrictingServerMixIn,
146 testserver_base.BrokenPipeHandlerMixIn, 146 testserver_base.BrokenPipeHandlerMixIn,
147 testserver_base.StoppableHTTPServer): 147 testserver_base.StoppableHTTPServer):
148 """This is a specialization of StoppableHTTPServer that add https support and 148 """This is a specialization of StoppableHTTPServer that add https support and
149 client verification.""" 149 client verification."""
150 150
151 def __init__(self, server_address, request_hander_class, pem_cert_and_key, 151 def __init__(self, server_address, request_hander_class, pem_cert_and_key,
152 ssl_client_auth, ssl_client_cas, 152 ssl_client_auth, ssl_client_cas,
153 ssl_bulk_ciphers, ssl_key_exchanges, 153 ssl_bulk_ciphers, ssl_key_exchanges, next_protos,
154 record_resume_info, tls_intolerant, signed_cert_timestamps, 154 record_resume_info, tls_intolerant, signed_cert_timestamps,
155 fallback_scsv_enabled, ocsp_response): 155 fallback_scsv_enabled, ocsp_response):
156 self.cert_chain = tlslite.api.X509CertChain() 156 self.cert_chain = tlslite.api.X509CertChain()
157 self.cert_chain.parsePemList(pem_cert_and_key) 157 self.cert_chain.parsePemList(pem_cert_and_key)
158 # Force using only python implementation - otherwise behavior is different 158 # Force using only python implementation - otherwise behavior is different
159 # depending on whether m2crypto Python module is present (error is thrown 159 # depending on whether m2crypto Python module is present (error is thrown
160 # when it is). m2crypto uses a C (based on OpenSSL) implementation under 160 # when it is). m2crypto uses a C (based on OpenSSL) implementation under
161 # the hood. 161 # the hood.
162 self.private_key = tlslite.api.parsePEMKey(pem_cert_and_key, 162 self.private_key = tlslite.api.parsePEMKey(pem_cert_and_key,
163 private=True, 163 private=True,
164 implementations=['python']) 164 implementations=['python'])
165 self.ssl_client_auth = ssl_client_auth 165 self.ssl_client_auth = ssl_client_auth
166 self.ssl_client_cas = [] 166 self.ssl_client_cas = []
wtc 2014/04/02 19:26:55 Nit: you may want to set self.next_protos = next_p
davidben 2014/04/03 19:38:36 Done.
167 if tls_intolerant == 0: 167 if tls_intolerant == 0:
168 self.tls_intolerant = None 168 self.tls_intolerant = None
169 else: 169 else:
170 self.tls_intolerant = (3, tls_intolerant) 170 self.tls_intolerant = (3, tls_intolerant)
171 self.signed_cert_timestamps = signed_cert_timestamps 171 self.signed_cert_timestamps = signed_cert_timestamps
172 self.fallback_scsv_enabled = fallback_scsv_enabled 172 self.fallback_scsv_enabled = fallback_scsv_enabled
173 self.ocsp_response = ocsp_response 173 self.ocsp_response = ocsp_response
174 self.next_protos = next_protos
174 175
175 for ca_file in ssl_client_cas: 176 for ca_file in ssl_client_cas:
176 s = open(ca_file).read() 177 s = open(ca_file).read()
177 x509 = tlslite.api.X509() 178 x509 = tlslite.api.X509()
178 x509.parse(s) 179 x509.parse(s)
179 self.ssl_client_cas.append(x509.subject) 180 self.ssl_client_cas.append(x509.subject)
180 self.ssl_handshake_settings = tlslite.api.HandshakeSettings() 181 self.ssl_handshake_settings = tlslite.api.HandshakeSettings()
181 if ssl_bulk_ciphers is not None: 182 if ssl_bulk_ciphers is not None:
182 self.ssl_handshake_settings.cipherNames = ssl_bulk_ciphers 183 self.ssl_handshake_settings.cipherNames = ssl_bulk_ciphers
183 if ssl_key_exchanges is not None: 184 if ssl_key_exchanges is not None:
(...skipping 13 matching lines...) Expand all
197 """Creates the SSL connection.""" 198 """Creates the SSL connection."""
198 199
199 try: 200 try:
200 self.tlsConnection = tlsConnection 201 self.tlsConnection = tlsConnection
201 tlsConnection.handshakeServer(certChain=self.cert_chain, 202 tlsConnection.handshakeServer(certChain=self.cert_chain,
202 privateKey=self.private_key, 203 privateKey=self.private_key,
203 sessionCache=self.session_cache, 204 sessionCache=self.session_cache,
204 reqCert=self.ssl_client_auth, 205 reqCert=self.ssl_client_auth,
205 settings=self.ssl_handshake_settings, 206 settings=self.ssl_handshake_settings,
206 reqCAs=self.ssl_client_cas, 207 reqCAs=self.ssl_client_cas,
208 nextProtos=self.next_protos,
207 tlsIntolerant=self.tls_intolerant, 209 tlsIntolerant=self.tls_intolerant,
208 signedCertTimestamps= 210 signedCertTimestamps=
209 self.signed_cert_timestamps, 211 self.signed_cert_timestamps,
210 fallbackSCSV=self.fallback_scsv_enabled, 212 fallbackSCSV=self.fallback_scsv_enabled,
211 ocspResponse = self.ocsp_response) 213 ocspResponse = self.ocsp_response)
212 tlsConnection.ignoreAbruptClose = True 214 tlsConnection.ignoreAbruptClose = True
213 return True 215 return True
214 except tlslite.api.TLSAbruptCloseError: 216 except tlslite.api.TLSAbruptCloseError:
215 # Ignore abrupt close. 217 # Ignore abrupt close.
216 return True 218 return True
(...skipping 1759 matching lines...) Expand 10 before | Expand all | Expand 10 after
1976 1978
1977 stapled_ocsp_response = None 1979 stapled_ocsp_response = None
1978 if self.__ocsp_server and self.options.staple_ocsp_response: 1980 if self.__ocsp_server and self.options.staple_ocsp_response:
1979 stapled_ocsp_response = self.__ocsp_server.ocsp_response 1981 stapled_ocsp_response = self.__ocsp_server.ocsp_response
1980 1982
1981 server = HTTPSServer((host, port), TestPageHandler, pem_cert_and_key, 1983 server = HTTPSServer((host, port), TestPageHandler, pem_cert_and_key,
1982 self.options.ssl_client_auth, 1984 self.options.ssl_client_auth,
1983 self.options.ssl_client_ca, 1985 self.options.ssl_client_ca,
1984 self.options.ssl_bulk_cipher, 1986 self.options.ssl_bulk_cipher,
1985 self.options.ssl_key_exchange, 1987 self.options.ssl_key_exchange,
1988 self.options.next_proto,
1986 self.options.record_resume, 1989 self.options.record_resume,
1987 self.options.tls_intolerant, 1990 self.options.tls_intolerant,
1988 self.options.signed_cert_timestamps_tls_ext.decode( 1991 self.options.signed_cert_timestamps_tls_ext.decode(
1989 "base64"), 1992 "base64"),
1990 self.options.fallback_scsv, 1993 self.options.fallback_scsv,
1991 stapled_ocsp_response) 1994 stapled_ocsp_response)
1992 print 'HTTPS server started on %s:%d...' % (host, server.server_port) 1995 print 'HTTPS server started on %s:%d...' % (host, server.server_port)
1993 else: 1996 else:
1994 server = HTTPServer((host, port), TestPageHandler) 1997 server = HTTPServer((host, port), TestPageHandler)
1995 print 'HTTP server started on %s:%d...' % (host, server.server_port) 1998 print 'HTTP server started on %s:%d...' % (host, server.server_port)
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
2172 'appear multiple times, indicating ' 2175 'appear multiple times, indicating '
2173 'multiple algorithms should be enabled.'); 2176 'multiple algorithms should be enabled.');
2174 self.option_parser.add_option('--ssl-key-exchange', action='append', 2177 self.option_parser.add_option('--ssl-key-exchange', action='append',
2175 help='Specify the key exchange algorithm(s)' 2178 help='Specify the key exchange algorithm(s)'
2176 'that will be accepted by the SSL server. ' 2179 'that will be accepted by the SSL server. '
2177 'Valid values are "rsa", "dhe_rsa". If ' 2180 'Valid values are "rsa", "dhe_rsa". If '
2178 'omitted, all algorithms will be used. This ' 2181 'omitted, all algorithms will be used. This '
2179 'option may appear multiple times, ' 2182 'option may appear multiple times, '
2180 'indicating multiple algorithms should be ' 2183 'indicating multiple algorithms should be '
2181 'enabled.'); 2184 'enabled.');
2185 # TODO(davidben): Add ALPN support to tlslite.
2186 self.option_parser.add_option('--next-proto', action='append',
2187 help='Specify the next proto value(s) to '
wtc 2014/04/02 19:26:55 Question: how are multiple values separated. By sp
davidben 2014/04/03 19:38:36 It should be the same as --ssl-bulk-cipher and fri
2188 'used with the NPN extension. If omitted, '
2189 'NPN will not be used used. This option '
wtc 2014/04/02 19:26:55 Nit: used used => used
2190 'may appear multiple times, indicating '
2191 'the list of preferred protos.')
wtc 2014/04/02 19:26:55 Nit: I don't understand why you said "preferred".
davidben 2014/04/03 19:38:36 Hrm. I think that's what I meant? That's a somewha
2182 self.option_parser.add_option('--file-root-url', default='/files/', 2192 self.option_parser.add_option('--file-root-url', default='/files/',
2183 help='Specify a root URL for files served.') 2193 help='Specify a root URL for files served.')
2184 2194
2185 2195
2186 if __name__ == '__main__': 2196 if __name__ == '__main__':
2187 sys.exit(ServerRunner().main()) 2197 sys.exit(ServerRunner().main())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698