Mikey’s Linux Field NotesAll topics

GUIDE 12 / WEB SERVICES

HTTPS & certificates

Distinguish encrypted connections from verified server identity.

4 quick lessons · Examples to adapt to your server
In this guide
Inspect certificate identityTest trust and hostname separatelyProtect the private keyCheck the full connection path

Commands use class paths and example filenames. Replace placeholders and inspect the target before making changes.

01

Inspect certificate identity

A certificate contains a public key and identity information. Compare the requested hostname with the Subject Alternative Name (SAN), then check issuer and validity dates.

COMMANDS & EXAMPLES
openssl x509 -in site.crt -noout -subject -issuer -dates
openssl x509 -in site.crt -noout -ext subjectAltName
openssl x509 -in site.crt -noout -serial -fingerprint -sha256
Field note

The production class certificate is self-signed. A browser warning is expected until you explicitly trust the correct certificate or install a certificate from a trusted issuer.

02

Test trust and hostname separately

--cacert supplies a trust file while retaining hostname verification. A certificate for ulc-119.ulcert.uw.edu does not match localhost merely because both reach the same server.

COMMANDS & EXAMPLES
curl --cacert site.crt -I https://ulc-119.ulcert.uw.edu
curl --cacert site.crt -I https://localhost
curl -k -I https://localhost
Field note

These examples assume site.crt is the correct certificate file. -k skips certificate verification; use it only for deliberate diagnostics, not proof of trusted identity.

03

Protect the private key

Nginx needs a certificate file and its matching private key. Keep the key outside the document root and Git, restrict access, and never publish its contents.

COMMANDS & EXAMPLES
sudo ls -lZ /etc/pki/nginx /etc/pki/nginx/private
sudo lsattr /etc/pki/nginx/private/private_key_prod.key
sudo nginx -t
Field note

In this class setup the private directory is root-owned 700, the key is root-owned 600, and SELinux labels are cert_t. The immutable i attribute prevents ordinary modification until deliberately removed for replacement.

04

Check the full connection path

Nginx must listen on 443, the firewall must permit HTTPS, and an external client must reach it. Compare a certificate fingerprint through a separate trusted channel when checking a peer.

COMMANDS & EXAMPLES
sudo ss -tlnp | grep :443
sudo firewall-cmd --zone=public --query-service=https
curl -I --max-time 5 https://ulc-119.ulcert.uw.edu
Field note

With the current self-signed class certificate, the last command may fail verification even when the connection works. Supply the trusted certificate with --cacert to verify identity.