Vithursa Mahendrarajah
Vithursa Mahendrarajah

Reputation: 1224

How to generate key store from certificates?

I am trying to create a keystore which has extension of jks from exsiting certificate file. Using the (CERT) certificate file I have, How can I create key-store (JKS) using Java key-tool?

Upvotes: 2

Views: 13920

Answers (1)

Siloft
Siloft

Reputation: 126

To generate keystores:

keytool -genkey -alias server -keyalg RSA -keystore server.jks
keytool -genkey -alias client -keyalg RSA -keystore client.jks

Getting server's self signed public key certificate and storing it in client's keystore and getting and storing client's self signed public key certificate in server's keystore:

keytool -export -file server.cert -keystore server.jks -storepass 123456 -alias server
keytool -export -file client.cert -keystore client.jks -storepass 123456 -alias client

Import certificate files in the JKS files:

keytool -import -file client.cert -keystore server.jks -storepass 123456 -alias client
keytool -import -file server.cert -keystore client.jks -storepass 123456 -alias server

Upvotes: 7

Related Questions