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 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 self.AuthDigestHandler, | 333 self.AuthDigestHandler, |
334 self.SlowServerHandler, | 334 self.SlowServerHandler, |
335 self.ChunkedServerHandler, | 335 self.ChunkedServerHandler, |
336 self.NoContentHandler, | 336 self.NoContentHandler, |
337 self.ServerRedirectHandler, | 337 self.ServerRedirectHandler, |
338 self.CrossSiteRedirectHandler, | 338 self.CrossSiteRedirectHandler, |
339 self.ClientRedirectHandler, | 339 self.ClientRedirectHandler, |
340 self.GetSSLSessionCacheHandler, | 340 self.GetSSLSessionCacheHandler, |
341 self.SSLManySmallRecords, | 341 self.SSLManySmallRecords, |
342 self.GetChannelID, | 342 self.GetChannelID, |
| 343 self.GetTokenBindingEKM, |
343 self.GetClientCert, | 344 self.GetClientCert, |
344 self.ClientCipherListHandler, | 345 self.ClientCipherListHandler, |
345 self.CloseSocketHandler, | 346 self.CloseSocketHandler, |
346 self.RangeResetHandler, | 347 self.RangeResetHandler, |
347 self.DefaultResponseHandler] | 348 self.DefaultResponseHandler] |
348 post_handlers = [ | 349 post_handlers = [ |
349 self.EchoTitleHandler, | 350 self.EchoTitleHandler, |
350 self.EchoHandler, | 351 self.EchoHandler, |
351 self.PostOnlyFileHandler, | 352 self.PostOnlyFileHandler, |
352 self.EchoMultipartPostHandler] + get_handlers | 353 self.EchoMultipartPostHandler] + get_handlers |
(...skipping 1157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1510 if not self._ShouldHandleRequest('/channel-id'): | 1511 if not self._ShouldHandleRequest('/channel-id'): |
1511 return False | 1512 return False |
1512 | 1513 |
1513 self.send_response(200) | 1514 self.send_response(200) |
1514 self.send_header('Content-Type', 'text/plain') | 1515 self.send_header('Content-Type', 'text/plain') |
1515 self.end_headers() | 1516 self.end_headers() |
1516 channel_id = bytes(self.server.tlsConnection.channel_id) | 1517 channel_id = bytes(self.server.tlsConnection.channel_id) |
1517 self.wfile.write(hashlib.sha256(channel_id).digest().encode('base64')) | 1518 self.wfile.write(hashlib.sha256(channel_id).digest().encode('base64')) |
1518 return True | 1519 return True |
1519 | 1520 |
| 1521 def GetTokenBindingEKM(self): |
| 1522 """Send a reply containing the EKM value for token binding from the TLS |
| 1523 layer.""" |
| 1524 |
| 1525 if not self._ShouldHandleRequest('/tokbind-ekm'): |
| 1526 return False |
| 1527 |
| 1528 ekm = self.server.tlsConnection.session.exportKeyingMaterial( |
| 1529 self.server.tlsConnection.version, "EXPORTER-Token-Binding", "", |
| 1530 False, 32) |
| 1531 self.send_response(200) |
| 1532 self.send_header('Content-Type', 'application/octet-stream') |
| 1533 self.end_headers() |
| 1534 self.wfile.write(ekm) |
| 1535 return True |
| 1536 |
1520 def GetClientCert(self): | 1537 def GetClientCert(self): |
1521 """Send a reply whether a client certificate was provided.""" | 1538 """Send a reply whether a client certificate was provided.""" |
1522 | 1539 |
1523 if not self._ShouldHandleRequest('/client-cert'): | 1540 if not self._ShouldHandleRequest('/client-cert'): |
1524 return False | 1541 return False |
1525 | 1542 |
1526 self.send_response(200) | 1543 self.send_response(200) |
1527 self.send_header('Content-Type', 'text/plain') | 1544 self.send_header('Content-Type', 'text/plain') |
1528 self.end_headers() | 1545 self.end_headers() |
1529 | 1546 |
(...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2310 'an anonymous user.') | 2327 'an anonymous user.') |
2311 self.option_parser.add_option('--disable-channel-id', action='store_true') | 2328 self.option_parser.add_option('--disable-channel-id', action='store_true') |
2312 self.option_parser.add_option('--disable-extended-master-secret', | 2329 self.option_parser.add_option('--disable-extended-master-secret', |
2313 action='store_true') | 2330 action='store_true') |
2314 self.option_parser.add_option('--token-binding-params', action='append', | 2331 self.option_parser.add_option('--token-binding-params', action='append', |
2315 default=[], type='int') | 2332 default=[], type='int') |
2316 | 2333 |
2317 | 2334 |
2318 if __name__ == '__main__': | 2335 if __name__ == '__main__': |
2319 sys.exit(ServerRunner().main()) | 2336 sys.exit(ServerRunner().main()) |
OLD | NEW |