小编Nil*_*ert的帖子

AttributeError:'Context'对象没有属性'wrap_socket'

我正在尝试设置一个使用OpenSSL上下文的Flask服务器.但是,由于我在不同的服务器上移动了脚本,因此无论我使用的是Python 2.7还是3.4,无论我选择哪种SSL方法(SSLv23/TLSv1/...),它都会引发以下错误:

  File "/usr/lib/python3.4/threading.py", line 920, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.4/threading.py", line 868, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.4/dist-packages/werkzeug/serving.py", line 602, in inner
    passthrough_errors, ssl_context).serve_forever()
  File "/usr/local/lib/python3.4/dist-packages/werkzeug/serving.py", line 506, in make_server
    passthrough_errors, ssl_context)
  File "/usr/local/lib/python3.4/dist-packages/werkzeug/serving.py", line 450, in __init__
    self.socket = ssl_context.wrap_socket(self.socket,
AttributeError: 'Context' object has no attribute 'wrap_socket'
Run Code Online (Sandbox Code Playgroud)

以下代码如下:

if __name__ == "__main__":
        context = SSL.Context(SSL.SSLv23_METHOD)
        context.use_privatekey_file('key.key')
        context.use_certificate_file('cert.crt')
        app.run(host='0.0.0.0', port=80, ssl_context=context, threaded=True, debug=True)
Run Code Online (Sandbox Code Playgroud)

非常感谢你提前!我很高兴能得到任何帮助

python openssl pyopenssl werkzeug flask

28
推荐指数
1
解决办法
2万
查看次数

标签 统计

flask ×1

openssl ×1

pyopenssl ×1

python ×1

werkzeug ×1