Skip to content

Instantly share code, notes, and snippets.

Embed
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(('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()
@h007

This comment has been minimized.

Copy link
Owner Author

@h007 h007 commented Jul 6, 2018

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 (公钥)

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

然后apt-get就恢复正常了。



python3 -m http.server 8000

cd /var/www/

$ python -m SimpleHTTPServer

https://stackoverflow.com/questions/6587507/how-to-install-pip-with-python-3

sudo apt-get install python-pip
sudo apt-get install python3-pip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment