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_client -alpn shows whether a server offers HTTP/2

Openssl
~/tips/tip-openssl-s-client-alpn-h2

echo | openssl s_client -connect example.com:443 -servername example.com -alpn h2 2>/dev/null | grep -i alpn

Check the protocol a server picks in the TLS handshake, such as h2 or http/1.1.

Browsers and servers agree on HTTP/2 during the TLS handshake, using an extension called ALPN. s_client can offer a protocol list and show what the server chose.

Offer HTTP/2 and look for the ALPN line:

echo | openssl s_client -connect example.com:443 -servername example.com -alpn h2 2>/dev/null | grep -i alpn
echo | openssl s_client -connect example.com:443 -servername example.com -alpn 'h2,http/1.1' 2>/dev/null | grep -i alpn

When the server supports it, you see ALPN protocol: h2. If it does not support anything you offered, the line reads No ALPN negotiated, and a browser would fall back to HTTP/1.1.

This is a lower level view than asking curl for the HTTP version. It shows the decision of the TLS layer only, before any HTTP request is sent. I find it useful when a reverse proxy sits in front of a service: the proxy is where ALPN happens, so the answer tells you what the proxy offers, whatever runs behind it.

HTTP/3 does not show up here. It runs over QUIC on UDP, not over this TCP connection, and servers announce it in an Alt-Svc header or a DNS HTTPS record instead. Also, a server may accept h2 in the handshake and still answer badly over HTTP/2, so a real request is the final test.

Further reading: OpenSSL: openssl-s_client, RFC 7301: TLS ALPN extension

Going deeper: Run degoog on Unraid as your own search page, compared with SearXNG and 4get

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