def upgradetotls(self):
"""
upgrade to a tls wrapped connection
:return: None
"""
# TODO: newer TLS version?
# noinspection PyUnresolvedReferences
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
# TODO: PLATFORM STAGECERTIFICATEFILE is not the correct name for this value, move to handler or set a different
# variable in TRANSPORT with the same initial value?
certkeyfile = sanatizefilename(self.handler.platform.options['STAGECERTIFICATEFILE']['Value'])
context.load_cert_chain(certfile=certkeyfile, keyfile=certkeyfile)
self.conn = context.wrap_bio(self.recvdataqueue.memorybio, self.senddataqueue.memorybio, server_side=True)
print_message("Waiting for connection and TLS handshake...")
while True:
try:
self.conn.do_handshake()
break
except (ssl.SSLWantReadError, ssl.SSLSyscallError):
pass
print_message("Upgrade to TLS done")
评论列表
文章目录