August 5, 2015

Change PKCS12 Keystore Password

1. Using openssl command


Using the following batch file:


cls
@echo off

@echo Using openssl command
@echo 
openssl pkcs12 -password pass:original-pass -passin pass:original-pass -in original-cert.p12 -passout pass:tmp1234 -out certificate-temp.pem 
openssl pkcs12 -export -passin pass:tmp1234 -in certificate-temp.pem -passout pass:test1234 -out certificate-final.p12
@echo

@echo Verify certificate-final.p12
@echo 
keytool -list -keystore certificate-final.p12 -storetype pkcs12


2. Using keytool command


Using the following batch file:


cls
@echo off

@echo 
@echo Using keytool
@echo 
keytool -importkeystore -srckeystore original-cert.p12 -srcstoretype PKCS12 -srcstorepass original-pass -destkeystore certificate-new-2.p12 -deststoretype PKCS12 -deststorepass test1234
@echo 
@echo Verify certificate-new-2.p12
@echo 
keytool -list -keystore certificate-new-2.p12 -storetype pkcs12