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.DefaultResponseHandler] | 347 self.DefaultResponseHandler] |
347 post_handlers = [ | 348 post_handlers = [ |
348 self.EchoTitleHandler, | 349 self.EchoTitleHandler, |
349 self.EchoHandler, | 350 self.EchoHandler, |
350 self.PostOnlyFileHandler, | 351 self.PostOnlyFileHandler, |
351 self.EchoMultipartPostHandler] + get_handlers | 352 self.EchoMultipartPostHandler] + get_handlers |
352 put_handlers = [ | 353 put_handlers = [ |
(...skipping 1156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1509 if not self._ShouldHandleRequest('/channel-id'): | 1510 if not self._ShouldHandleRequest('/channel-id'): |
1510 return False | 1511 return False |
1511 | 1512 |
1512 self.send_response(200) | 1513 self.send_response(200) |
1513 self.send_header('Content-Type', 'text/plain') | 1514 self.send_header('Content-Type', 'text/plain') |
1514 self.end_headers() | 1515 self.end_headers() |
1515 channel_id = bytes(self.server.tlsConnection.channel_id) | 1516 channel_id = bytes(self.server.tlsConnection.channel_id) |
1516 self.wfile.write(hashlib.sha256(channel_id).digest().encode('base64')) | 1517 self.wfile.write(hashlib.sha256(channel_id).digest().encode('base64')) |
1517 return True | 1518 return True |
1518 | 1519 |
| 1520 def GetTokenBindingEKM(self): |
| 1521 """Send a reply containing the EKM value for token binding from the TLS |
| 1522 layer.""" |
| 1523 |
| 1524 if not self._ShouldHandleRequest('/tokbind-ekm'): |
| 1525 return False |
| 1526 |
| 1527 ekm = self.server.tlsConnection.exportKeyingMaterial( |
| 1528 "EXPORTER-Token-Binding", "", False, 32) |
| 1529 self.send_response(200) |
| 1530 self.send_header('Content-Type', 'application/octet-stream') |
| 1531 self.end_headers() |
| 1532 self.wfile.write(ekm) |
| 1533 return True |
| 1534 |
1519 def GetClientCert(self): | 1535 def GetClientCert(self): |
1520 """Send a reply whether a client certificate was provided.""" | 1536 """Send a reply whether a client certificate was provided.""" |
1521 | 1537 |
1522 if not self._ShouldHandleRequest('/client-cert'): | 1538 if not self._ShouldHandleRequest('/client-cert'): |
1523 return False | 1539 return False |
1524 | 1540 |
1525 self.send_response(200) | 1541 self.send_response(200) |
1526 self.send_header('Content-Type', 'text/plain') | 1542 self.send_header('Content-Type', 'text/plain') |
1527 self.end_headers() | 1543 self.end_headers() |
1528 | 1544 |
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2161 'an anonymous user.') | 2177 'an anonymous user.') |
2162 self.option_parser.add_option('--disable-channel-id', action='store_true') | 2178 self.option_parser.add_option('--disable-channel-id', action='store_true') |
2163 self.option_parser.add_option('--disable-extended-master-secret', | 2179 self.option_parser.add_option('--disable-extended-master-secret', |
2164 action='store_true') | 2180 action='store_true') |
2165 self.option_parser.add_option('--token-binding-params', action='append', | 2181 self.option_parser.add_option('--token-binding-params', action='append', |
2166 default=[], type='int') | 2182 default=[], type='int') |
2167 | 2183 |
2168 | 2184 |
2169 if __name__ == '__main__': | 2185 if __name__ == '__main__': |
2170 sys.exit(ServerRunner().main()) | 2186 sys.exit(ServerRunner().main()) |
OLD | NEW |