tlsa.sh 1.1 KB

1234567891011121314151617181920212223242526272829
  1. #!/bin/bash
  2. #@brief Generates TLSA Fingerprints for Let's Encrypt Intermediate Certs
  3. # Intermediate Certificates Cross-signed by IdenTrust in pem format
  4. # URLs: https://letsencrypt.org/certificates/
  5. le="https://letsencrypt.org/certs/lets-encrypt-x3-cross-signed.pem
  6. https://letsencrypt.org/certs/lets-encrypt-r3-cross-signed.pem
  7. https://letsencrypt.org/certs/lets-encrypt-e1.pem
  8. https://letsencrypt.org/certs/lets-encrypt-x4-cross-signed.pem
  9. https://letsencrypt.org/certs/lets-encrypt-r4-cross-signed.pem
  10. https://letsencrypt.org/certs/lets-encrypt-e2.pem
  11. "
  12. cert=`tempfile`
  13. echo ";TLSA Record Resource Data for Let's Encrypt Intermediate Certificates" > tlsa.txt
  14. for url in $le
  15. do
  16. curl -s $url > $cert
  17. echo -e -n "\n;" >> tlsa.txt
  18. cat $cert | openssl x509 -noout -subject >> tlsa.txt
  19. if [[ $url == *"encrypt-e"* ]]; then
  20. cat $cert | openssl x509 -noout -pubkey | openssl ec -pubin -outform DER | openssl dgst -sha256 -hex | awk '{print "2 1 1", $NF}' >> tlsa.txt
  21. else
  22. cat $cert | openssl x509 -noout -pubkey | openssl rsa -pubin -outform DER | openssl dgst -sha256 -hex | awk '{print "2 1 1", $NF}' >> tlsa.txt
  23. fi
  24. done
  25. rm $cert