-
-
Save h007/196575c0d68d3832d246f1a32c07e6fd to your computer and use it in GitHub Desktop.
Simple HTTPS server in Python 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
from http.server import HTTPServer,SimpleHTTPRequestHandler | |
from socketserver import BaseServer | |
import ssl | |
httpd = HTTPServer(('0.0.0.0', 1443), SimpleHTTPRequestHandler) | |
httpd.socket = ssl.wrap_socket (httpd.socket, certfile='certificate.pem', keyfile='privatekey.pem', server_side=True) | |
httpd.serve_forever() |
to create the cert without installing anything:
openssl genrsa > privatekey.pem
openssl req -new -x509 -key privatekey.pem -out certificate.pem -days 365
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://github.com/FiloSottile/mkcert
On Linux, install certutil
sudo apt-get update
sudo apt install libnss3-tools
https://github.com/FiloSottile/mkcert/releases
https://github.com/FiloSottile/mkcert/releases/download/v0.9.1/mkcert-v0.9.1-linux-amd64
chmod 755 mkcert-v0.9.1-linux-amd64
mkcert -install
mkcert example.com '*.example.org' myapp.dev localhost 127.0.0.1 ::1
使用 firefox 证书导入
about:preferences#advanced
Certificate Manager
Authorities
import
rootCA.pem (公钥)
有趣的互联网工具 #003 使用 mkcert 生成本地 SSL 证书 Use mkcert to generate a local SSL certificate