【2021-09-24】python搭配mkcert启动本地https服务

发布时间:2022-07-05 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了【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

【2021-09-24】python搭配mkcert启动本地https服务

mkcert下载地址:![添加图片描述](https://img-bLOG.csdnimg.cn/5f42f3ee3b884b95b5487e1cd419ef79.jpg?x-oss-PRocess=image/watermark,tyPE_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBA6L-35b-D5YWU,size_20,color_FFFFFF,t_70,g_se,x_16)
https://gIThub.com/FiloSottile/mkcert/releases/latest

1、管理员启动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 ssl

httpd = 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()

脚本宝典总结

以上是脚本宝典为你收集整理的【2021-09-24】python搭配mkcert启动本地https服务全部内容,希望文章能够帮你解决【2021-09-24】python搭配mkcert启动本地https服务所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。