Akshay Deo

Do(nt) Code Seriously

Creating .keystore From .cert and .key


A quick not for creating .keystore using a set of certificates including root, intermediate and domain certs.

First create a .p12 using private key and domain certificate.
openssl pkcs12 -export -in <domain_cert> -inkey <private_key> -certfile <domain_cert> -name "<name>" -out <p12_name>.p12

Create keystore file using
keytool -importkeystore -destkeystore <keystore_name>.keystore -srckeystore <p12_name>.p12 -srcstoretype pkcs12 -alias <alias_name>

Then import the other certificates using
keytool -import -trustcacerts -alias root -file <cert_file> -keystore <keystore_name>.keystore

Comments