Skip to content

Commit a65c36d

Browse files
committed
make server ask for KeyUpdate with /keyupdate
when client performs a "GET /keyupdate" request, the server will now send a KeyUpdate mesasge to client
1 parent 7e2fd04 commit a65c36d

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

scripts/tls.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
from tlslite.utils.compat import b2a_hex, a2b_hex, time_stamp
3838
from tlslite.utils.dns_utils import is_valid_hostname
3939
from tlslite.utils.cryptomath import getRandomBytes
40+
from tlslite.constants import KeyUpdateMessageType
4041

4142
try:
4243
from tack.structures.Tack import Tack
@@ -530,10 +531,22 @@ def serverCmd(argv):
530531
settings.maxVersion = max_ver
531532
settings.virtual_hosts = virtual_hosts
532533

533-
class MySimpleHTTPHandler(SimpleHTTPRequestHandler):
534+
class MySimpleHTTPHandler(SimpleHTTPRequestHandler, object):
534535
"""Buffer the header and body of HTTP message."""
535536
wbufsize = -1
536537

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+
537550
class MyHTTPServer(ThreadingMixIn, TLSSocketServerMixIn, HTTPServer):
538551
def handshake(self, connection):
539552
print("About to handshake...")
@@ -588,7 +601,7 @@ def handshake(self, connection):
588601
return False
589602
else:
590603
raise
591-
604+
592605
connection.ignoreAbruptClose = True
593606
printGoodConnection(connection, stop-start)
594607
printExporter(connection, expLabel, expLength)

0 commit comments

Comments
 (0)