部分代码
if __name__ == '__main__':
# app.run(host="0.0.0.0",port=5004)
app.run(host="0.0.0.0", port=443, ssl_context=(
"/Users/jiangyd/Downloads/dc/ca/serevr.crt",
"/Users/jiangyd/Downloads/dc/ca/server.key"))
报错如下
Traceback (most recent call last):
File "app.py", line 76, in <module>
"/Users/jiangyd/Downloads/dc/ca/serevr.crt",
File "/Users/jiangyd/PycharmProjects/untitled16/venv/lib/python3.7/site-packages/flask/app.py", line 922, in run
run_simple(t.cast(str, host), port, self, **options)
File "/Users/jiangyd/PycharmProjects/untitled16/venv/lib/python3.7/site-packages/werkzeug/serving.py", line 1008, in run_simple
inner()
File "/Users/jiangyd/PycharmProjects/untitled16/venv/lib/python3.7/site-packages/werkzeug/serving.py", line 957, in inner
fd=fd,
File "/Users/jiangyd/PycharmProjects/untitled16/venv/lib/python3.7/site-packages/werkzeug/serving.py", line 781, in make_server
host, port, app, request_handler, passthrough_errors, ssl_context, fd=fd
File "/Users/jiangyd/PycharmProjects/untitled16/venv/lib/python3.7/site-packages/werkzeug/serving.py", line 702, in __init__
ssl_context = load_ssl_context(*ssl_context)
File "/Users/jiangyd/PycharmProjects/untitled16/venv/lib/python3.7/site-packages/werkzeug/serving.py", line 595, in load_ssl_context
ctx.load_cert_chain(cert_file, pkey_file)
FileNotFoundError: [Errno 2] No such file or directory
您好,从图中意思可看出应该是SSL证书路径不对导致。您pyopenssl 模块安装的话,如果没有证书请生成证书:
pip install pyopenssl
openssl req -x509 -newkey rsa:4096 -nodes -out cert.pem -keyout key.pem -days 365
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。