Packet Notes

Cybersecurity
field notes.

Follow a web request from a DNS answer to a TLS certificate to the headers a browser receives.

Open the notebook

The notebook

Run these commands on your Linux machine. Replace example.com with your site’s hostname.

DNSRead the address records

Ask your configured resolver for the IPv4 and IPv6 addresses separately. The answer lines include the remaining cache lifetime (TTL), in seconds.

dig example.com A +noall +answer
dig example.com AAAA +noall +answer

An empty answer can have several causes. Run the query again without the display options to see the response status.

TLSVerify the certificate and hostname

Connect to port 443. Send the site name during the handshake and ask OpenSSL to check that the certificate covers that hostname.

openssl s_client -connect example.com:443 \
  -servername example.com -verify_hostname example.com \
  -verify_return_error -brief </dev/null

Look for Verification: OK. A verification error can point to a hostname mismatch, an expired certificate, or a chain that your system cannot validate.

HTTPInspect the response headers

Make a GET request, print the headers, and discard the body. On this notebook, look for Content-Security-Policy and X-Content-Type-Options.

curl -sS -D - -o /dev/null https://example.com/

A 3xx status with a Location header means the server is redirecting you. Add -L to follow it and see each response.

References