Skip to content

Commit

Permalink
tls.py: trigger PHA on accessing /secret
Browse files Browse the repository at this point in the history
  • Loading branch information
tomato42 committed Nov 26, 2019
1 parent 2cc4f49 commit 0e552e6
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions scripts/tls.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,28 @@ def do_GET(self):
else:
raise ValueError("Invalid return from "
"send_keyupdate_request")
if self.path.startswith('/secret'):
try:
for i in self.connection.request_post_handshake_auth():
pass
except ValueError:
self.wfile.write(b'HTTP/1.0 401 Certificate authentication'
b' required\r\n')
self.wfile.write(b'Connection: close\r\n')
self.wfile.write(b'Content-Length: 0\r\n\r\n')
return
b = self.connection.read(0, 0)
if self.connection.session.clientCertChain:
print(" Got client certificate in post-handshake auth: "
"{0}".format(self.connection.session
.clientCertChain.getFingerprint()))
else:
print(" No certificate from client received")
self.wfile.write(b'HTTP/1.0 401 Certificate authentication'
b' required\r\n')
self.wfile.write(b'Connection: close\r\n')
self.wfile.write(b'Content-Length: 0\r\n\r\n')
return
return super(MySimpleHTTPHandler, self).do_GET()

class MyHTTPServer(ThreadingMixIn, TLSSocketServerMixIn, HTTPServer):
Expand Down

0 comments on commit 0e552e6

Please sign in to comment.