Extract one alias from pkcs12 keystore in pkcs12 format

2.3k views Asked by At

I am trying to export one of the aliases from the pkcs12 keystore to a new "empty" keystore of the same type (i.e. pkcs12).

keytool -importkeystore -v -srckeystore vault.p12 -destkeystore p2.p12 -srcstoretype PKCS12 -deststoretype PKCS12 -srcstorepass yyyy -deststorepass xxxx -srcalias p2 -destalias p2

This command gives an empty p2.p12 file and a failure:

[Storing p986wasuser.p12] keytool error (likely untranslated): java.io.IOException: Error in storing the key store: Given final block not properly padded
1

There are 1 answers

0
bjornb On

As I managed to find out this was a working way to solve my problem:

keytool -importkeystore -srckeystore source.p12 -destkeystore alias.p12 -srcstorepass password -srcstoretype pkcs12 -deststoretype PKCS12 -srcalias alias -deststorepass pass -destkeypass pass