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

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

Issue 212883008: Add DHE_RSA support to tlslite. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update patch. 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
« no previous file with comments | « no previous file | third_party/tlslite/README.chromium » ('j') | 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 145
146 146
147 class HTTPSServer(tlslite.api.TLSSocketServerMixIn, 147 class HTTPSServer(tlslite.api.TLSSocketServerMixIn,
148 testserver_base.ClientRestrictingServerMixIn, 148 testserver_base.ClientRestrictingServerMixIn,
149 testserver_base.BrokenPipeHandlerMixIn, 149 testserver_base.BrokenPipeHandlerMixIn,
150 testserver_base.StoppableHTTPServer): 150 testserver_base.StoppableHTTPServer):
151 """This is a specialization of StoppableHTTPServer that add https support and 151 """This is a specialization of StoppableHTTPServer that add https support and
152 client verification.""" 152 client verification."""
153 153
154 def __init__(self, server_address, request_hander_class, pem_cert_and_key, 154 def __init__(self, server_address, request_hander_class, pem_cert_and_key,
155 ssl_client_auth, ssl_client_cas, ssl_bulk_ciphers, 155 ssl_client_auth, ssl_client_cas,
156 ssl_bulk_ciphers, ssl_key_exchanges,
156 record_resume_info, tls_intolerant, signed_cert_timestamps, 157 record_resume_info, tls_intolerant, signed_cert_timestamps,
157 fallback_scsv_enabled, ocsp_response): 158 fallback_scsv_enabled, ocsp_response):
158 self.cert_chain = tlslite.api.X509CertChain() 159 self.cert_chain = tlslite.api.X509CertChain()
159 self.cert_chain.parsePemList(pem_cert_and_key) 160 self.cert_chain.parsePemList(pem_cert_and_key)
160 # Force using only python implementation - otherwise behavior is different 161 # Force using only python implementation - otherwise behavior is different
161 # depending on whether m2crypto Python module is present (error is thrown 162 # depending on whether m2crypto Python module is present (error is thrown
162 # when it is). m2crypto uses a C (based on OpenSSL) implementation under 163 # when it is). m2crypto uses a C (based on OpenSSL) implementation under
163 # the hood. 164 # the hood.
164 self.private_key = tlslite.api.parsePEMKey(pem_cert_and_key, 165 self.private_key = tlslite.api.parsePEMKey(pem_cert_and_key,
165 private=True, 166 private=True,
166 implementations=['python']) 167 implementations=['python'])
167 self.ssl_client_auth = ssl_client_auth 168 self.ssl_client_auth = ssl_client_auth
168 self.ssl_client_cas = [] 169 self.ssl_client_cas = []
169 if tls_intolerant == 0: 170 if tls_intolerant == 0:
170 self.tls_intolerant = None 171 self.tls_intolerant = None
171 else: 172 else:
172 self.tls_intolerant = (3, tls_intolerant) 173 self.tls_intolerant = (3, tls_intolerant)
173 self.signed_cert_timestamps = signed_cert_timestamps 174 self.signed_cert_timestamps = signed_cert_timestamps
174 self.fallback_scsv_enabled = fallback_scsv_enabled 175 self.fallback_scsv_enabled = fallback_scsv_enabled
175 self.ocsp_response = ocsp_response 176 self.ocsp_response = ocsp_response
176 177
177 for ca_file in ssl_client_cas: 178 for ca_file in ssl_client_cas:
178 s = open(ca_file).read() 179 s = open(ca_file).read()
179 x509 = tlslite.api.X509() 180 x509 = tlslite.api.X509()
180 x509.parse(s) 181 x509.parse(s)
181 self.ssl_client_cas.append(x509.subject) 182 self.ssl_client_cas.append(x509.subject)
182 self.ssl_handshake_settings = tlslite.api.HandshakeSettings() 183 self.ssl_handshake_settings = tlslite.api.HandshakeSettings()
183 if ssl_bulk_ciphers is not None: 184 if ssl_bulk_ciphers is not None:
184 self.ssl_handshake_settings.cipherNames = ssl_bulk_ciphers 185 self.ssl_handshake_settings.cipherNames = ssl_bulk_ciphers
186 if ssl_key_exchanges is not None:
187 self.ssl_handshake_settings.keyExchangeNames = ssl_key_exchanges
185 188
186 if record_resume_info: 189 if record_resume_info:
187 # If record_resume_info is true then we'll replace the session cache with 190 # If record_resume_info is true then we'll replace the session cache with
188 # an object that records the lookups and inserts that it sees. 191 # an object that records the lookups and inserts that it sees.
189 self.session_cache = RecordingSSLSessionCache() 192 self.session_cache = RecordingSSLSessionCache()
190 else: 193 else:
191 self.session_cache = tlslite.api.SessionCache() 194 self.session_cache = tlslite.api.SessionCache()
192 testserver_base.StoppableHTTPServer.__init__(self, 195 testserver_base.StoppableHTTPServer.__init__(self,
193 server_address, 196 server_address,
194 request_hander_class) 197 request_hander_class)
(...skipping 1780 matching lines...) Expand 10 before | Expand all | Expand 10 after
1975 ' exiting...') 1978 ' exiting...')
1976 1979
1977 stapled_ocsp_response = None 1980 stapled_ocsp_response = None
1978 if self.__ocsp_server and self.options.staple_ocsp_response: 1981 if self.__ocsp_server and self.options.staple_ocsp_response:
1979 stapled_ocsp_response = self.__ocsp_server.ocsp_response 1982 stapled_ocsp_response = self.__ocsp_server.ocsp_response
1980 1983
1981 server = HTTPSServer((host, port), TestPageHandler, pem_cert_and_key, 1984 server = HTTPSServer((host, port), TestPageHandler, pem_cert_and_key,
1982 self.options.ssl_client_auth, 1985 self.options.ssl_client_auth,
1983 self.options.ssl_client_ca, 1986 self.options.ssl_client_ca,
1984 self.options.ssl_bulk_cipher, 1987 self.options.ssl_bulk_cipher,
1988 self.options.ssl_key_exchange,
1985 self.options.record_resume, 1989 self.options.record_resume,
1986 self.options.tls_intolerant, 1990 self.options.tls_intolerant,
1987 self.options.signed_cert_timestamps_tls_ext.decode( 1991 self.options.signed_cert_timestamps_tls_ext.decode(
1988 "base64"), 1992 "base64"),
1989 self.options.fallback_scsv, 1993 self.options.fallback_scsv,
1990 stapled_ocsp_response) 1994 stapled_ocsp_response)
1991 print 'HTTPS server started on %s:%d...' % (host, server.server_port) 1995 print 'HTTPS server started on %s:%d...' % (host, server.server_port)
1992 else: 1996 else:
1993 server = HTTPServer((host, port), TestPageHandler) 1997 server = HTTPServer((host, port), TestPageHandler)
1994 print 'HTTP server started on %s:%d...' % (host, server.server_port) 1998 print 'HTTP server started on %s:%d...' % (host, server.server_port)
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
2163 'times, indicating multiple CA names should ' 2167 'times, indicating multiple CA names should '
2164 'be sent in the request.') 2168 'be sent in the request.')
2165 self.option_parser.add_option('--ssl-bulk-cipher', action='append', 2169 self.option_parser.add_option('--ssl-bulk-cipher', action='append',
2166 help='Specify the bulk encryption ' 2170 help='Specify the bulk encryption '
2167 'algorithm(s) that will be accepted by the ' 2171 'algorithm(s) that will be accepted by the '
2168 'SSL server. Valid values are "aes256", ' 2172 'SSL server. Valid values are "aes256", '
2169 '"aes128", "3des", "rc4". If omitted, all ' 2173 '"aes128", "3des", "rc4". If omitted, all '
2170 'algorithms will be used. This option may ' 2174 'algorithms will be used. This option may '
2171 'appear multiple times, indicating ' 2175 'appear multiple times, indicating '
2172 'multiple algorithms should be enabled.'); 2176 'multiple algorithms should be enabled.');
2177 self.option_parser.add_option('--ssl-key-exchange', action='append',
2178 help='Specify the key exchange algorithm(s)'
2179 'that will be accepted by the SSL server. '
2180 'Valid values are "rsa", "dhe_rsa". If '
2181 'omitted, all algorithms will be used. This '
2182 'option may appear multiple times, '
2183 'indicating multiple algorithms should be '
2184 'enabled.');
2173 self.option_parser.add_option('--file-root-url', default='/files/', 2185 self.option_parser.add_option('--file-root-url', default='/files/',
2174 help='Specify a root URL for files served.') 2186 help='Specify a root URL for files served.')
2175 2187
2176 2188
2177 if __name__ == '__main__': 2189 if __name__ == '__main__':
2178 sys.exit(ServerRunner().main()) 2190 sys.exit(ServerRunner().main())
OLDNEW
« no previous file with comments | « no previous file | third_party/tlslite/README.chromium » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698