OLD | NEW |
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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 self.SlowServerHandler, | 330 self.SlowServerHandler, |
331 self.ChunkedServerHandler, | 331 self.ChunkedServerHandler, |
332 self.ContentTypeHandler, | 332 self.ContentTypeHandler, |
333 self.NoContentHandler, | 333 self.NoContentHandler, |
334 self.ServerRedirectHandler, | 334 self.ServerRedirectHandler, |
335 self.CrossSiteRedirectHandler, | 335 self.CrossSiteRedirectHandler, |
336 self.ClientRedirectHandler, | 336 self.ClientRedirectHandler, |
337 self.GetSSLSessionCacheHandler, | 337 self.GetSSLSessionCacheHandler, |
338 self.SSLManySmallRecords, | 338 self.SSLManySmallRecords, |
339 self.GetChannelID, | 339 self.GetChannelID, |
| 340 self.GetClientCert, |
340 self.ClientCipherListHandler, | 341 self.ClientCipherListHandler, |
341 self.CloseSocketHandler, | 342 self.CloseSocketHandler, |
342 self.RangeResetHandler, | 343 self.RangeResetHandler, |
343 self.DefaultResponseHandler] | 344 self.DefaultResponseHandler] |
344 post_handlers = [ | 345 post_handlers = [ |
345 self.EchoTitleHandler, | 346 self.EchoTitleHandler, |
346 self.EchoHandler, | 347 self.EchoHandler, |
347 self.PostOnlyFileHandler, | 348 self.PostOnlyFileHandler, |
348 self.EchoMultipartPostHandler] + get_handlers | 349 self.EchoMultipartPostHandler] + get_handlers |
349 put_handlers = [ | 350 put_handlers = [ |
(...skipping 1173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1523 if not self._ShouldHandleRequest('/channel-id'): | 1524 if not self._ShouldHandleRequest('/channel-id'): |
1524 return False | 1525 return False |
1525 | 1526 |
1526 self.send_response(200) | 1527 self.send_response(200) |
1527 self.send_header('Content-Type', 'text/plain') | 1528 self.send_header('Content-Type', 'text/plain') |
1528 self.end_headers() | 1529 self.end_headers() |
1529 channel_id = bytes(self.server.tlsConnection.channel_id) | 1530 channel_id = bytes(self.server.tlsConnection.channel_id) |
1530 self.wfile.write(hashlib.sha256(channel_id).digest().encode('base64')) | 1531 self.wfile.write(hashlib.sha256(channel_id).digest().encode('base64')) |
1531 return True | 1532 return True |
1532 | 1533 |
| 1534 def GetClientCert(self): |
| 1535 """Send a reply containing the client certificate that the client provided."
"" |
| 1536 |
| 1537 if not self._ShouldHandleRequest('/client-cert'): |
| 1538 return False |
| 1539 |
| 1540 self.send_response(200) |
| 1541 self.send_header('Content-Type', 'text/plain') |
| 1542 self.end_headers() |
| 1543 |
| 1544 cert_present = self.server.tlsConnection.session.clientCertChain != None |
| 1545 if cert_present: |
| 1546 self.wfile.write('got a client cert') |
| 1547 else: |
| 1548 self.wfile.write('got no client cert') |
| 1549 return True |
| 1550 |
1533 def ClientCipherListHandler(self): | 1551 def ClientCipherListHandler(self): |
1534 """Send a reply containing the cipher suite list that the client | 1552 """Send a reply containing the cipher suite list that the client |
1535 provided. Each cipher suite value is serialized in decimal, followed by a | 1553 provided. Each cipher suite value is serialized in decimal, followed by a |
1536 newline.""" | 1554 newline.""" |
1537 | 1555 |
1538 if not self._ShouldHandleRequest('/client-cipher-list'): | 1556 if not self._ShouldHandleRequest('/client-cipher-list'): |
1539 return False | 1557 return False |
1540 | 1558 |
1541 self.send_response(200) | 1559 self.send_response(200) |
1542 self.send_header('Content-Type', 'text/plain') | 1560 self.send_header('Content-Type', 'text/plain') |
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2299 'alert immediately after the handshake.') | 2317 'alert immediately after the handshake.') |
2300 self.option_parser.add_option('--no-anonymous-ftp-user', | 2318 self.option_parser.add_option('--no-anonymous-ftp-user', |
2301 dest='no_anonymous_ftp_user', | 2319 dest='no_anonymous_ftp_user', |
2302 default=False, action='store_true', | 2320 default=False, action='store_true', |
2303 help='If set, the FTP server will not create ' | 2321 help='If set, the FTP server will not create ' |
2304 'an anonymous user.') | 2322 'an anonymous user.') |
2305 | 2323 |
2306 | 2324 |
2307 if __name__ == '__main__': | 2325 if __name__ == '__main__': |
2308 sys.exit(ServerRunner().main()) | 2326 sys.exit(ServerRunner().main()) |
OLD | NEW |