学习链接: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://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()