RealSteel
RealSteel

Reputation: 1931

Importing a SSL certificate into a Java Keystore via a pfx file

I've a requirement where I need to import a SSL Certificate into java keystore.
Basically, I'm new to this SSL and Java.
I'm from dotnet background, so its quiet complicated doing these things.

Things I've done :

Generated a pfx certificate from IIS.
Followed this link from here and navigated to the java bin folder and created a new keystore by following command.

keytool -genkey -alias customcertificate.pfx -keyalg RSA -keysize 2048 -keystore customkeystore  

I've given the same password for this command, like the password used for pfx generated file.

After that, I've given all the details it asked and the keystore was created.

Now in the second step, I've emptied the keystore as the tutorial said.

keytool -delete -alias customcertificate -keystore customkeystore

I've also tested with this command that nothing is in keystore

keytool -v -list -keystore customkeystore

Now in the third step, I got a little confused with the JKS file generation.

The command is this way :

keytool -v -importkeystore -srckeystore customcertificate.pfx -srcstoretype PKCS12 -destkeystore customkeystore -deststoretype JKS

I've entered both source and destination passwords, and I was confused where the JKS file would be saved.

Do I need to create a empty file with JKS extension and then given the path at the importing command after destkeystore?

Can anyone, please go through the link and guide me the correct way of doing this?

Thanks in advance.

The response after the last step is : Entry for alias le-*******-******-*****-**** successfully imported. Import command completed: 1 entries successfully imported, 0 entries failed or cancelled [Storing hivemqkeystore]

Upvotes: 0

Views: 10249

Answers (1)

Shueb Dalvi
Shueb Dalvi

Reputation: 1

THe keystore file will be generated at location at which above command was entered. For e.g. above command was entered at C:\somedir\ then the keystore.jks will be at C:somedir\keystore.jks

Hope this helps !

Upvotes: 0

Related Questions