Question

Using bash, how do I convert a directory full .pem files (with CERTIFICATE and RSA PRIVATE KEY) into pkcs12 (.p12) format with a given password? I have 1,000 .pem files to convert and don't want to do it one-by-one.

Was it helpful?

Solution

for f in *.pem; do openssl pkcs12 -export -out "`basename $f .pem`.p12" -inkey "$f" -in "$f" -certfile ./myca.pem -password pass:myPass; done

Where 'myPass' (no quotes) is the password, and myca.pem is the CA.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top