brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: openssl s_server -www starts a throwaway HTTPS test server

Openssl
~/tips/tip-openssl-s-server-www

openssl s_server -accept 8443 -cert cert.pem -key key.pem -www

Run a tiny TLS server to test a certificate, a client or a firewall rule.

Sometimes I want to test a certificate or a client before any real web server is set up. OpenSSL includes a small TLS server for exactly that.

Start it with a certificate and key on a free port:

openssl s_server -accept 8443 -cert cert.pem -key key.pem -www

With -www it answers every HTTP request with a status page that shows the TLS version, the cipher and the ciphers it supports. Test it from another terminal:

curl --cacert ca.pem https://localhost:8443/

It is handy for a few jobs: checking that a fresh certificate and key load and match, testing whether a client trusts your CA, or checking a firewall or port forward before the real service exists. With -WWW (capitals) it serves files from the current folder instead of the status page. To serve a chain, add the intermediates with -cert_chain chain.pem.

This is a test tool, not a web server. It handles one connection at a time, has no access control, and with -WWW serves whatever is in that folder to anyone who can reach the port. Bind it to a port only your own machine or LAN can reach, and stop it with Ctrl+C when you are done.

Further reading: OpenSSL: openssl-s_server

More Openssl tips openssl s_client -connect 203.0.113.10:443 -servername example.com </dev/null | openssl x509 -noout -subject openssl x509 -in cert.pem -days 365 -signkey key.pem -out cert-new.pem printf %s hello | openssl dgst -sha256 -hmac secret openssl pkcs12 -legacy -in old.pfx -nokeys echo 'aGVsbG8gd29ybGQ=' | openssl base64 -d All Openssl tips (34) All topics

Link