- Signs Java ARchive (JAR) files.
- Verifies the signatures and integrity of signed JAR files.
Sign a JAR file
Before signing a JAR file, ensure that the keys stored on the CryptoHub needed for signing are accessible.1
First, go to the
$JAVA_HOME/bin directory:Shell
2
Then, run the following keytool command to list all of the keys on the CryptoHub that the configured identity has access to. The
-providerArg flag passes the pkcs11.cfg file you created earlier:Shell
When prompted for the KeyStore password in this command and the following commands, enter the CryptoHub identity password configured inside the
<CRYPTO-OPR-PASS> tag in the fxpkcs11.cfg file.The response should be similar to the following:
Shell
3
Now that you know the keys needed for code signing are accessible, run the following command to sign a JAR file using the CryptoHub-stored keys. The Refer to the Oracle documentation to learn about flags that you can use in the preceding jarsigner command, such as -tsa and -tsacert.
-providerArg flag passes the pkcs11.cfg file:You must run the command from the same directory where you stored the
example.jar file.Shell
You must copy and paste the alias in the last field of the preceding jarsigner command (for example,
jarsigner-demo-1784141140:jarsigner-demo) from the output of the keytool -list command in step 2. The CryptoHub assigns the on-token key an alias in the form <alias>-<id>:<alias>, which differs from the short -alias value you passed to keytool -genkeypair.If the signing succeeds, the response includes a confirmation message that says, jar signed.
Verify the signature
Run the following command to verify the signature of the signed JAR file output from the previous jarsigner command,demo_signed.jar:
Shell
If the verification succeeds, the response includes a confirmation message that says, jar verified.

