We got used to running python -m http.server
command to quickly spin up a local http server that we could grab some files over. A lot of use cases these days require HTTPS to be used, however, so some of the quick and dirty testing operations now turn a bit more painful. This is a ready-made script that spins up a simple http server with SSL/TLS on, using the self-signed certificate.
If file cert.pem
is not detected, script will try to create it during startup. It will contain both certificate and private key, and the private key is not passphrase protected. While it is acceptable for testing locally quickly, it is completely unreasonable and unacceptable for anything even remotely exposed to real life scenarios.
If you wan't to generate your own own cert.pem, or need to regenerate the new one (default expiration is set to 365 days), run the following command:
openssl req -newkey rsa:2048 -x509 -days 365 -nodes -out cert.pem -keyout cert.pem