Using `curl` to check a TLS certificate on a websocket (`ws` or `wss`)

Checks the TLS cert on the connection:

curl -v \
     --insecure \
       --include \
     --no-buffer \
     --header "Connection: Upgrade" \
     --header "Upgrade: websocket" \
     --header "Host: example.com:80" \
     --header "Origin: http://example.com:80" \
     --header "Sec-WebSocket-Key: SGVsbG8sIHdvcmxkIQ==" \
     --header "Sec-WebSocket-Version: 13" \
     "https://example.com:4000/socket.io/?EIO=3&transport=websocket" 2>&1| awk 'BEGIN { cert=0 } /^\* Server certificate:/ { cert=1 } /^\*/ { if (cert) print }'

This article was updated on 2023-01-25

I'm nabeards.

I'm a full stack JavaScript developer.

I travel full time, a.k.a., Professional Wanderer, a.k.a., Digital Nomad.