Using Curl to access web pages

Curl cert validation

curl -v --cert-status https://vigor.nz

Curl with selfsigned cert to ip

export CURL_IP="10.1.1.5"
export CURL_HOST="myhost.co.nz"
export CURL_CA_FILE="ca_my_selfsigned_cert.pem"

curl -i --cacert ${CURL_CA_FILE} --resolve ${CURL_HOST}:443:${CURL_IP} "https://${CURL_HOST}/"

Set headers

Use Curl to measure web page response

Curl with http proxy

Curl and set useragent

Curl with host header/SNI


Curl check SSL/TLS certs

for url in \
  https://google.com \
  https://microsoft.com \
    ; do
        host="${url#https://}"
        host="${host%%/*}"
        expires=$(echo | openssl s_client -servername "$host" -connect "$host:443" 2>/dev/null | openssl x509 -noout -enddate | cut -d= -f2)
        expires_at=$(date -j -f "%b %e %T %Y %Z" "$expires" +%s)
        days_remaining=$(( (expires_at - $(date +%s)) / 86400 ))
        printf '# %-28s %4d days (%s)\n' "$host" "$days_remaining" "$expires"
done

CategoryLinux