当前位置:首页 > python > 正文内容

flask 服务添加ssl 证书

root5年前 (2021-06-10)python2506

1、利用openssl生成自用的ssl证书

  • 利用openssl 生成证书

openssl genrsa -des3 -out server.key 2048

不要密码:再执行 一下:openssl rsa -in server.key -out server.key

openssl req -new -x509 -key server.key -out ca.crt -days 3650

openssl req -new -key server.key -out server.csr

openssl x509 -req -days 3650 -in server.csr -CA ca.crt -CAkey server.key -CAcreateserial -out server.crt


  • flask启动按照下面进行配置

app.run(host='0.0.0.0',port=5000,debug=True,ssl_context=('./server.crt','./server.key'))

2、通过阿里云或者宝塔等平台免费申请ssl证书

  • 在云平台上找到域名相关的栏目

image.pngimage.png

  • 加入到代码中

app.run('0.0.0.0', debug=True, port=5000, ssl_context=('your_path/XXXX.pem', 'your_path/XXXX.key'))


flask添加ssl参考链接

https://blog.csdn.net/warrah/article/details/82995770

https://blog.csdn.net/dyingstraw/article/details/82698639

openssl生成ssl证书参考链接

https://blog.csdn.net/wenjinglian/article/details/84508588



扫描二维码推送至手机访问。

版权声明:本文由一叶知秋发布,如需转载请注明出处。

本文链接:https://www.zhiqiu.top/?id=122

分享给朋友:

相关文章

python 的configparser 读取配置文件遇到%特殊符号

test.ini 配置文件中有mysql的密码,且密码含有“%”这个特殊符号因为%在py是转义符的含义需要对该字符转义即修改  %  为 %%用%对%进行转义...

selenium控制webdriver  设置请求头。只能设置简单的。自定义和固定的格式无法修改成功

selenium控制webdriver 设置请求头。只能设置简单的。自定义和固定的格式无法修改成功

time selenium webdriver options webdriver.() options.() options.( options.() browser webdriver....

python跟pip不是同一个版本的坑

python执行默认是Python2.7但是pip默认确实pip3的用pip install 安装包只会安装到python3环境里面指回pip vim /usr/local/bin/pip把 第一行的#!/usr/bin...

Python的多线程并发限制

maxConnections connection_lock (maxConnections)在开启线程前执行connection_lock.acquire()线程执行结束执行connection_lock.releas...

python2的pip 不能使用或者使用总是报错

python2的pip 不能使用或者使用总是报错

python2.7   当然可能还有其他情况有的是pip版本升级过高,有的是pip有点问题无法执行pip的命令升级python2的 pip 一定要小心推荐命令:pip install --upgrad...

python 调用linux命令 subprocess.popen

import subprocesscommd = "echo 123"p1 = subprocess.Popen(commd, shell=True, stdout=subprocess.PIPE, stder...