Code signing
Java Jarsigner

Create Java keystore

5min

In this section, you use Java keytool commands to generate a new key pair on the , create a Certificate Signing Request (CSR), issue a certificate through an internal or external CA, and import the signed certificate and accompanying CA certificate into a Java keystore.

These tasks enable you to use the signed certificate to sign a JAR file by using jarsigner in the next section.

Because the keytool application is part of the JDK 8 installation, you don't need extra configuration to run the commands in this section.

1 | Generate a server key pair and self-signed certificate

Run the following command to generate the key pair and certificate:

The -alias field sets a name to identify the key pair and certificate being generated. It can be any name (such as JarsignerDemo).

Shell


When you run the preceding command, the keytool application prompts you for information about the server certificate you want to generate, as shown in the following sample:

Text


2 | Generate and export a CSR

1

Execute the following command:

Shell

2

Enter the keystore password.

3

Use either a third party or internal CA to sign the CSR.

3| Import the CA Root certificate

Run the following command to import the certificate:

1
Shell

Shell


4 | Import the certificate signed by CA

Run the following command to import the signed certificate:

1
Shell

Shell