Guest User

Untitled

a guest
Jul 16th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. # This script takes one or more x509 certificates in .PEM format (from
  4. # stdin or files listed on command line) and adds helpful "bag
  5. # attributes" before each certificate. This makes it easier for
  6. # humans to identify the contents of the bundle.
  7. #
  8. # Requires (g)awk and openssl's x509 command line utility.
  9. #
  10. # Output fields included can be specified via openssl-x509 options:
  11. #
  12. # subject= /C=US/O=DigiCert Inc/CN=DigiCert SHA2 Secure Server CA
  13. # issuer= /C=US/O=DigiCert Inc/OU=www.digicert.com/CN=DigiCert Global Root CA
  14. # notBefore=Mar 8 12:00:00 2013 GMT
  15. # notAfter=Mar 8 12:00:00 2023 GMT
  16. # SHA256 Fingerprint=15:4C:43:3C:49:19:29:C5:EF:68:6E:83:8E:32:36:64:A0:0E:6A:0D:82:2C:CC:95:8F:B4:DA:B0:3E:49:A0:8F
  17. # -----BEGIN CERTIFICATE-----
  18. # ...
  19. # -----END CERTIFICATE-----
  20.  
  21. awk -vZ="openssl x509 -subject -issuer -email -dates -sha256 -fingerprint" \
  22. '/^-----BEGIN/{b=Z;x=1}x{print|b}/^-----END/{close(b);x=0;print""}' "$@"
Add Comment
Please, Sign In to add comment