Guest User

Check wosign certificates

a guest
Jul 7th, 2017
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.78 KB | None | 0 0
  1. #!/usr/bin/env bash
  2. #vi: set ft=sh :
  3.  
  4. AFTER_DATE="$(date --date "October 21 2016" +%s)"
  5.  
  6. # Or read from a file with something like `cat hosts | while read host; do`
  7. for host in "google.com"; do
  8.     echo "$host"
  9.     cert_info="$(openssl s_client -connect $host:443 < /dev/null 2>/dev/null | sed -n '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | openssl x509 -text -noout)"
  10.     grep 'O=WoSign CA Limited' <<< "$cert_info" &>/dev/null || continue
  11.     echo "  Is WoSign certificate"
  12.  
  13.     VALIDITY_DATE="$(sed -n 's/\s*Not Before: \(.*\)$/\1/p' <<< "$cert_info")"
  14.     VALIDITY_TIMESTAMP="$(date --date "$VALIDITY_DATE" +%s)"
  15.  
  16.     [[ $VALIDITY_TIMESTAMP -le $AFTER_DATE ]] && continue
  17.     echo "  Is signed after cutoff date"
  18.  
  19.     echo ">>>>> Certificate for $host is INVALID"
  20. done
Advertisement
Add Comment
Please, Sign In to add comment