Skip to content

Instantly share code, notes, and snippets.

@kristopherjohnson
Last active May 13, 2022 23:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kristopherjohnson/7ebccfce2a5b587c8c64d2eaed440e91 to your computer and use it in GitHub Desktop.
Save kristopherjohnson/7ebccfce2a5b587c8c64d2eaed440e91 to your computer and use it in GitHub Desktop.
AWK script that gets certificate expiration info from PEM-format certificate data
#!/usr/bin/env awk -f
# Processes PEM output to print certificate expiration information.
#
# Example: Print expiration dates for all certificates on macOS
#
# security find-certificate -a -p | awk -f cert_expire.awk
#
# Example: Print expiration dates for all "iPhone Developer" certificates on macOS
#
# security find-certificate -a -c "iPhone Developer:" -p | awk -f cert_expire.awk
BEGIN {
formatter = "/usr/bin/openssl x509 -noout -subject -startdate -enddate"
}
/BEGIN CERTIFICATE/, /END CERTIFICATE/ { print | formatter }
/END CERTIFICATE/ { close(formatter); print "----" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment