|
37 | 37 | from tlslite.utils.compat import b2a_hex, a2b_hex, time_stamp |
38 | 38 | from tlslite.utils.dns_utils import is_valid_hostname |
39 | 39 | from tlslite.utils.cryptomath import getRandomBytes |
| 40 | +from tlslite.constants import KeyUpdateMessageType |
40 | 41 |
|
41 | 42 | try: |
42 | 43 | from tack.structures.Tack import Tack |
@@ -530,10 +531,22 @@ def serverCmd(argv): |
530 | 531 | settings.maxVersion = max_ver |
531 | 532 | settings.virtual_hosts = virtual_hosts |
532 | 533 |
|
533 | | - class MySimpleHTTPHandler(SimpleHTTPRequestHandler): |
| 534 | + class MySimpleHTTPHandler(SimpleHTTPRequestHandler, object): |
534 | 535 | """Buffer the header and body of HTTP message.""" |
535 | 536 | wbufsize = -1 |
536 | 537 |
|
| 538 | + def do_GET(self): |
| 539 | + """Simple override to send KeyUpdate to client.""" |
| 540 | + if self.path.startswith('/keyupdate'): |
| 541 | + for i in self.connection.send_keyupdate_request( |
| 542 | + KeyUpdateMessageType.update_requested): |
| 543 | + if i in (0, 1): |
| 544 | + continue |
| 545 | + else: |
| 546 | + raise ValueError("Invalid return from " |
| 547 | + "send_keyupdate_request") |
| 548 | + return super(MySimpleHTTPHandler, self).do_GET() |
| 549 | + |
537 | 550 | class MyHTTPServer(ThreadingMixIn, TLSSocketServerMixIn, HTTPServer): |
538 | 551 | def handshake(self, connection): |
539 | 552 | print("About to handshake...") |
@@ -588,7 +601,7 @@ def handshake(self, connection): |
588 | 601 | return False |
589 | 602 | else: |
590 | 603 | raise |
591 | | - |
| 604 | + |
592 | 605 | connection.ignoreAbruptClose = True |
593 | 606 | printGoodConnection(connection, stop-start) |
594 | 607 | printExporter(connection, expLabel, expLength) |
|
0 commit comments