【问题标题】:SSLContext is hanging in python 3.6.3SSLContext 挂在 python 3.6.3 中
【发布时间】:2020-06-04 17:26:35
【问题描述】:

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

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

ssl.SSLContext(ssl.PROTOCOL_TLSv1_2) # 这个函数在python 3.6.3中调用hanging.

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

self = _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()

【问题讨论】:

    标签: python ssl openssl ssl-certificate


    【解决方案1】:

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

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

    谢谢!!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-22
      • 1970-01-01
      • 1970-01-01
      • 2018-05-17
      • 1970-01-01
      相关资源
      最近更新 更多