How to change .p12 password?
Asked Answered
C

1

7

I have a .p12 file and I need to change its password. And this new password have to be "1234"

I already tried to do this with Keytool :

keytool -importkeystore -srckeystore authentification.p12 -srcstoretype PKCS12 -srcstorepass "2600807934-Auth" -destkeystore new.p12 -deststoretype PKCS12 -storepass 1234

But i got an error message telling me that the new password must contains at lesat 6 char.

Do you no another way to do this ? (I got other .p12 files with "1234" as password, so it is possible)

Conjunctiva answered 21/12, 2018 at 14:8 Comment(0)
C
16

You can do this with two subsequent openssl pkcs12 commands. First, to extract your contents from the .p12 file, use

openssl pkcs12 -in contents.p12 -out contents.txt

It will ask you for the password to access contents.p12 (1234 in your case), as well as a new password for encrypting the private key that ends up in contents.txt (and an additional time to verify you did not make a typo).

The you can use the following command to re-construct a .p12 from contents.txt:

openssl pkcs12 -export -in contents.txt -out contents_new.p12

It will ask you for the password that you used to encrypt the private key in the previous step, as well as a new password for the .p12 bundle (and again an additional time to verify you did not make a typo).

Capstone answered 21/12, 2018 at 21:39 Comment(1)
Can we ignore the first password ("for encrypting the private key that ends up in contents.txt") and leave it empty? Isn't the second password ("for the .p12 bundle") enough? In the above process, it seems the first password is useless (we open and remove it in the second step)! Not?Fishtail

© 2022 - 2024 — McMap. All rights reserved.