How to retrieve a certificate and private key from a .p12 file.
I needed it when I was writing AWS SNS with Terraform.
$ openssl pkcs12 -in xxxx.p12 -nodes -nokeys -out certificate.pem
$ openssl pkcs12 -in xxxx.p12 -nodes -nocerts -out privatekey.oem
This way, however, the file will have text starting with NoArgument at the beginning.
NoArgument doesn't do any harm when it's in, but I was curious about it, so I tried to remove it.
The secret key was converted without NoArgument by executing the following command.
I gave up on the certificate because I couldn't find a way to erase the text.
I'll post it if I can.
$ openssl pkcs12 -in xxxx.p12 -nodes -nocerts | openssl rsa -out privatekey.pem