Working with ansible vault

December 19, 2023

Easy editing in VSCode:

PFX to cert file:

# PFX -> PEM (certificate only)
openssl pkcs12 -in filename.pfx -out cert.pem -clcerts -nokeys

PFX to key file:

# PFX -> PEM (key only)
openssl pkcs12 -in filename.pfx -out key_with_passphrase.pem -nocerts -nodes
 
# Remove passphrase from key
openssl rsa -in key_with_passphrase.pem -out key.key -passin pass:passphrase
 
# openssl pkcs12 -in filename.pfx -nocerts -nodes -out key.pem
 

Decrypt ssl certificate and display as raw text:

openssl x509 -in cert.pem -text -noout