java - Convert SSL .p12 to .pem with or without OpenSSL -


i have .p12 file need converted .pem file - add username , password in process.

using openssl, command is...

openssl pkcs12 -in passbookcert.p12 -clcerts -nokeys -out passcertificate.pem -passin pass:

i can run terminal session , works perfectly.

however, need , want write java code this. best way it?

don't in java! seriously.

depending on operating system, try for-loop in bash when being on linux, or powershell or whatever used on windows (batch scripts?). on mac have shell work linux.

something this:

for in *; openssl pkcs12 -in "$i".p12 -clcerts -nokeys -out "$i".pem -passin pass; done 

for illustration purposes, cannot used in terminal directly:

for in *      openssl pkcs12 -in "$i".p12 -clcerts -nokeys -out "$i".pem -passin pass done 

maybe should not use same password on files, should do.

if not want use directly on terminal within folder have certfiles located, can put scriptfile , more stuff it.

create empty text file, put shebang in first line (#!/bin/bash), code on line below. make file executable (chmod +x filename) , can run directly. (./filename)

you can pass parameters bash scripts, too.


Comments