SSLContext is hanging in python 3.6.3



我对python和sto这个论坛都很陌生。我必须创建支持 tls1.2 安全性的 Http 服务器。早些时候我们有python 2.6。现在我们需要 tls1.2 安全性。Python 2.6 不支持 TLS1.2 安全性。所以我们更新到 python 3.6.3。

我已经为 http 服务器处理程序编写了示例代码,但它不起作用。 当我尝试使用 print 语句进行调试时。它并没有超越SSLContext((函数调用。我用谷歌搜索了很多,但没有找到任何答案。

啪。SSLContext(ssl.PROTOCOL_TLSv1_2( # 这个函数调用 python 3.6.3 中的挂起。

当我看到 ssl.py 文件时,我发现下面的函数调用没有响应。我不是如何解决这个问题的。期待蟒蛇专家的帮助。

自我 = _SSLContext。(CLS,协议(

[提示:ssl.wrap_socket(( 函数调用在 pythong 2.6 中工作。但在 python 3.6.3 版本中不起作用。调试后,我发现它在SSLContext((创建函数调用时挂起。

感谢您的帮助!!

---------------------这是我的完整代码----------------------------------

from http.server import HTTPServer, SimpleHTTPRequestHandler
import ssl
httpd = HTTPServer(('localhost', 9449), SimpleHTTPRequestHandler)
print("Line 1")
sock = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2) // This line hangs
print("Line 2")
httpd.socket = ssl.wrap_socket(httpd.socket, certfile='/tmp/cert-and-key.pem', server_side=True)
httpd.serve_forever()

我从 github.com 中找到了答案。它可能对某人有用,所以我正在发布链接。

https://github.com/openssl/openssl/issues/12077

谢谢!!

最新更新