(Use keytool -list to see the contents of the keystore.) Make sure the certificate category is set to Identity. Upload the client certificate file in JKS format. Enter the keystore and key passwords used to create the JKS store.
- Keytool View Jks
- Keytool Import Crt
- Convert Jks To Pem Keytool
- Generate Jks File From Crt And Key Using Keytool
- How To Create Jks Keystore
- Keytool Jks Command
While testing web services or performing any web service test using https URLs which are secure, there are chances that we could face the issue as client side authentication required. Sometimes client certificate or SSL throws javax.net.ssl.SSLHandshakeException error. This usually happens when browser or tool like Jmeter that you use for web services testing, does not find the certificate or not able to read the certificate sent from client side.
If you are facing such kind of issues, and you need create .jks file to provide the authentication or if you are not able to convert .der or .crt or .p12 file to .jks file, please follow the steps to perform the conversion or create .jks file using keytool.exe.
Create a JKS file using.crt file and private key You must generate a p12 file which comprises of private and.crt file openssl pkcs12 -export -in server.crt -inkey server.key -certfile server.crt. Hi, Please give me the exact keytool commands to convert.key and.crt files to.jks file of keystore. I am unable to import.key to.jks. Please send me both commands. Create a keystore using Keytool: While we create a Java keystore we will first create the.jks file that will initially only contain the private key using keytool utility. Keytool -genkey -keystore keystore.jks -alias ssl -keyalg RSA -sigalg SHA256withRSA -validity 365 -keysize 2048-alias is an option to mention an Alias Name to your key entry. You can use openssl and keytool openssl pkcs12 -export -out domainname.pfx -inkey domainname.key -in domainname.crt -password pass:mypassword keytool -importkeystore -srckeystore domainname.pfx -srcstoretype pkcs12 -srcalias 1 -srcstorepass mypassword -destkeystore domainname.jks -deststoretype jks -deststorepass mypassword -destalias myalias.
- Keytool.exe comes by default with all the latest Java. Make sure java is available in your system.
- Open browser and load https URL will prompt you to install the certificate if not installed in your browser.
- Click on AddException and then Confirm Security Exception will install the certificate in the browser.
- Click on lock icon shown in the address bar.
- Click on More Information and then View Certificate.
- Click on Details tab and then click on Export button.
- Save the certificate in java bin folder with any name.
- Change the file extension with .p12 extension. Example (certificate.p12)

- Now open command prompt and navigate to java bin folder.
- keytool -importcert -alias mycert -file certificate.p12 -keystore certificate.jks -storepass password
- Once you hit enter it will ask you to answer Trust this certificate? Type yes and hit enter again.
Here you have generated .jks file with file name certificate.jks and the file will be located in Java bin folder.
Keytool View Jks
Now you have successfully converted .p12 file to jks file. The same process you can apply to change any file like .der file or .crt file to convert in .jks file. What all you have to do is to replace the .p12 file with your file and give the same name in command prompt while executing the command.
Java Keytool is a command line utility which can be used to generate keystores and then we can export keys and self signed public certificates from it with different command options provided by Java Key Tool. In this step by step Java Keytool tutorial, I will explain how to create a key store using Java Keytool and then how to export public certificate from JKS file using Java Keytool.
Java Keytool is a command line utility which is available as part of JDK installation and is available in the bin folder of your JDK installation. Java Key tool is used to create self signed certificates. This tool provides different options including generation of keystores, exporting private keys and public certificates from keystores and also importing certificates in the keystore.
Keytool Import Crt
If you prefer to watch all the steps in a video format, you can watch below video on TutorialsPedia YouTube Channel explaining step by step process to generate keystore using Java KeyTool and exporting Public Certificate from Keystore file.
If you prefer going through all the steps of JKS Tutorial in Text format, continue reading below.
Now we will proceed with step by step tuorial for creating Keystore and exporting public certificate from it using Java Keytool.
Java Keytool Tutorial Step 1: Create JKS File using Java KeyTool
Convert Jks To Pem Keytool

To crate a keystore in JKS format, we will use keytool with genkey options as below where we specify alias, algorithm to be used and also name of the keystore file along with its location where it needs to be saved.
keytool -genkey -alias tutorialspedia -keyalg RSA -keystore “C:testtutorialspedia.jks”
You will be prompted fro the keystore password. You can provide any password with minimum length of 6 characters. You will be asked to enter password twice and then you will be prompted to provide various information including first & last name, name of organization unit, organization name, name of city, state and country and then you will be asked to confirm all provided details if everything is correct. If you want to have different password for key than the keystore password, you can provide a different password otherwise you can press enter and same password will be used for keystore and key file.
Generate Jks File From Crt And Key Using Keytool
As you can see in the screenshot below, we have successfully created a keystore file in JKS format in our provided location.
Java KeyTool Tutorial Step 2: Export Public Certificate from JKS Keystore File
How To Create Jks Keystore
From our generated kestore, we can export public certificate in .cer format using below command:
keytool -export -alias tutorialspedia -file “C:testtutorialspedia_public_cert.cer” -keystore “C:testtutorialspedia.jks”
The above command will export public certificate in a file with the name as specified in -file option. When running above command you will be prompted to provide keystore password and then file will get created containing your public certificate as you can see in screenshot below:
Keytool Jks Command
If you want to learn how you can create self signed certificates using Portecle GUI tool, refer to the below Tutorial:
Alternatively, you can also look into another tutorial I wrote about how to generate self signed certificates, keys and CSR using openSSL.