Python|【2021-09-24】python搭配mkcert启动本地https服务
【Python|【2021-09-24】python搭配mkcert启动本地https服务】学习链接:https://blog.dteam.top/posts/2019-04/%E6%9C%AC%E5%9C%B0https%E5%BF%AB%E9%80%9F%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88mkcert.html

文章图片
mkcert下载地址:
https://github.com/FiloSottile/mkcert/releases/latest1、管理员启动cmd
2、安装:mkcert-v1.4.3-windows-amd64.exe -install
3、查看本地mkcert保存路径:mkcert-v1.4.3-windows-amd64.exe -CAROOT
4、生成自签证书:mkcert-v1.4.3-windows-amd64.exe localhost 127.0.0.1 ::1
5、python3使用生成的证书文件:下面的代码
python3版本
import http.server as BaseHTTPServer
import sslhttpd = BaseHTTPServer.HTTPServer(('0.0.0.0', 8090), BaseHTTPServer.SimpleHTTPRequestHandler)
httpd.socket = ssl.wrap_socket(httpd.socket, certfile='./localhost+2.pem', keyfile='./localhost+2-key.pem', server_side=True, ssl_version=ssl.PROTOCOL_TLSv1_2)
print("开启https服务成功...")
httpd.serve_forever()
推荐阅读
- 宽容谁
- 我要做大厨
- 增长黑客的海盗法则
- 画画吗()
- 2019-02-13——今天谈梦想()
- 远去的风筝
- 三十年后的广场舞大爷
- 叙述作文
- 20190302|20190302 复盘翻盘
- 学无止境,人生还很长