File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -564,6 +564,28 @@ def do_GET(self):
564564 else :
565565 raise ValueError ("Invalid return from "
566566 "send_keyupdate_request" )
567+ if self .path .startswith ('/secret' ):
568+ try :
569+ for i in self .connection .request_post_handshake_auth ():
570+ pass
571+ except ValueError :
572+ self .wfile .write (b'HTTP/1.0 401 Certificate authentication'
573+ b' required\r \n ' )
574+ self .wfile .write (b'Connection: close\r \n ' )
575+ self .wfile .write (b'Content-Length: 0\r \n \r \n ' )
576+ return
577+ self .connection .read (0 , 0 )
578+ if self .connection .session .clientCertChain :
579+ print (" Got client certificate in post-handshake auth: "
580+ "{0}" .format (self .connection .session
581+ .clientCertChain .getFingerprint ()))
582+ else :
583+ print (" No certificate from client received" )
584+ self .wfile .write (b'HTTP/1.0 401 Certificate authentication'
585+ b' required\r \n ' )
586+ self .wfile .write (b'Connection: close\r \n ' )
587+ self .wfile .write (b'Content-Length: 0\r \n \r \n ' )
588+ return
567589 return super (MySimpleHTTPHandler , self ).do_GET ()
568590
569591 class MyHTTPServer (ThreadingMixIn , TLSSocketServerMixIn , HTTPServer ):
You can’t perform that action at this time.
0 commit comments