Generating a Keystore

  1. Open command prompt and navigate to %JDK_HOME%/bin directory. JDK8 is used in this exercise.
  2. Enter the following command, and then press Enter:

keytool -keysize 2048 –keystore fiorano.jks –genkey –alias fiorano -keyalg RSA

  1. Enter a password for the keystore. The password used in this example is' fioranopass'.
  2. Answer all the Organization details. When prompted for the First Name and Last Name, enter the fully qualified domain name (FQDN), Host Name or URL to which you plan to apply the certificate.

If you are requesting a Wildcard certificate, please add an asterisk (star) on the left side of the Common Name (e.g., .mydomain.com or www.mydomain.com). This secures all subdomains of the Common Name.

  1. A screenshot is shown below. All the details provided in this step must be valid. CA authorities might reject the Certificate Signing Request (CSR) if any of these values are invalid.



Generating a Certificate Signing Request (CSR)

  1. To Generate a CSR, enter the following command, and then press Enter.

keytool –keystore fiorano.jks –certreq –alias fiorano –keyalg rsa –file fiorano.csr -sigalg SHA256withRSA

  1. Provide keystore password provided in the section "Generating a Keystore" (fioranopass is used in our example)


  1. A file fiorano.csr is created which contains the certificate signing request. This certificate signing request (CSR) has to be passed on to your external/third party CA (Certificate Authority).


The CA will authenticate the certificate requestor (usually off-line) and will return a certificate or certificate chain, used to replace the existing certificate chain (which initially consists of a self-signed certificate) in the keystore.

Generating SSL certificate using CSR

We need to go to a third-party CA website to request an SSL certificate using the CSR we generated. Third party CA websites like http://www.thawte.com/, https://www.godaddy.com etc. can be used to generate SSL certificates. In this example, Thawte.com's 21-day trial certificate is generated and used but the trial certificate is not recommended for any usage.

To copy your CSR, open fiorano.csr file generated in section2, highlight it from ----BEGIN CERTIFICATE REQUEST to END CERTIFICATE REQUEST----, press Enter, and then paste it in CA website online application to generate SSL certificates.

Using certificates from a CA authority

CA authorities will send you a signed certificate, intermediate certificate and root certificate. Now we need to import all these certificates into fiorano.jks keystore file.
Note: The intermediate and root certificate should have different alias names, but the signed certificate should be imported with the same alias that was used while creating a certificate pair in "Generating a Keystore" section. Download your certificate files from your certificate authority and save them to the same directory as the keystore that you created during the CSR creation process.
The certificate will only work with the same keystore that you initially created the CSR with. The certificates must be installed to your keystore in the correct order.
Assuming sslcert.pem, intermediate.pem and root.pem are my certificates (received from CA authorities), the following commands are used to import all the certificates into the keystore.
Command1: keytool -importcert -alias intermediate -file intermediate.pem -keystore fiorano.jks -storepass fioranopass
Command2: keytool -importcert -alias root -file root.pem -keystore fiorano.jks -storepass fioranopass
Command3: keytool -importcert -alias fiorano -file sslcert.pem -keystore fiorano.jks -storepass fioranopass



All the certificates are added to our keystore and it is ready to use.
When root and intermediate certificates are added to the keystore, you see a message "Certificate was added to keystore". When primary certificate is added to the keystore, the message says "Certificate reply was installed in keystore".
If you don't see any errors in this process, you can jump to the section "Using the Keystore in Fiorano".

Listing keystore entries

You can list the keystore and check if all the certificates are imported successfully.
Command: keytool -list -keystore fiorano.jks -storepass fioranopass

If -v option is specified in the above command, you can see the certificate chain length for fiorano alias.
Command: keytool -list -v -keystore fiorano.jks -storepass fioranopass

Adaptavist ThemeBuilder EngineAtlassian Confluence