Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Simple HTTPS server in Python 3
#!/usr/bin/env python3
from http.server import HTTPServer,SimpleHTTPRequestHandler
from socketserver import BaseServer
import ssl
httpd = HTTPServer(('', 1443), SimpleHTTPRequestHandler)
httpd.socket = ssl.wrap_socket (httpd.socket, certfile='certificate.pem', keyfile='privatekey.pem', server_side=True)
Copy link

h007 commented Jul 6, 2018

On Linux, install certutil
sudo apt-get update

sudo apt install libnss3-tools

chmod 755 mkcert-v0.9.1-linux-amd64

mkcert -install

mkcert '*' localhost ::1

使用 firefox 证书导入
Certificate Manager
rootCA.pem (公钥)

root@kali:~/.local/share# cd mkcert/
root@kali:~/.local/share/mkcert# ls
rootCA-key.pem  rootCA.pem

有趣的互联网工具 #003 使用 mkcert 生成本地 SSL 证书 Use mkcert to generate a local SSL certificate

解决Could not get lock /var/cache/apt/archives/lock
在ubuntu apt-get upgrade的时候,遇到:

E: Could not get lock /var/cache/

apt/archives/lock - open (11 Resource temporarily unavailable)
E: Unable to lock the download directory


sudo rm -rf /var/cache/apt/archives/lock
sudo apt-get update


python3 -m http.server 8000

cd /var/www/

$ python -m SimpleHTTPServer

sudo apt-get install python-pip
sudo apt-get install python3-pip

Copy link

dncpax commented Dec 8, 2021

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