Skip to main content

Certificate Services Support

User-added image

User-added image

Signing Java Code

Before you begin this procedure you must have:

  • an Entrust EV Code Signing Certificate (installed on a token)
  • correctly installed and configured the SafeNet Authentication Client version 10.7, to manage the token
  • the Java Development Kit (JDK) installed (available from the Oracle Web site)

To sign a .jar file with an EV Code Signing Certificate:

1. Connect your EV code signing token to the USB port of your computer.

2. In any line editor (Notepad, for example), create a text file containing the lines below and save it to your JDK bin folder (for example, C:\Program Files (x86)\Java\jre1.8.0_65\bin) as enToken.cfg.


name=enToken
library=c:\WINDOWS\System32\eTPKCS11.dll


3 .Open a command prompt and move to the JDK bin folder. Run the following command
to obtain the alias name for the private key:


Keytool -list -keystore NONE -storetype PKCS11 -providerclass
sun.security.pkcs11.SunPKCS11 -providerArg ./enToken.cfg


You will be prompted for the keystore password. This is the password that you created when you enrolled for the token.

Example:
User-added image
In the example above, the private key ALIAS is:


le-734f69fa-ba68-4e73-a7ca-027815a944c9

You will use your ALIAS in the next step.

4. To use the certificate to sign JAR file, run the following command:


jarsigner -tsa
http://timestamp.entrust.net/rfc3161ts2 -verbose -keystore NONE -storetype PKCS11 -providerClass sun.security.pkcs11.SunPKCS11 -providerArg ./enToken.cfg <your JAR filename> <your private key ALIAS>

Example:
User-added image

5.  To verify that the JAR file has been signed correctly, please use the command below:


jarsigner -verify -verbose <your JAR filename>

Example:
User-added image

Common Errors:

"jarsigner error: java.lang.ClassNotFoundException: sun.security.pkcs11.SunPKCS11"

You will encounter this error when you are using the wrong version of Java Development Kit, specifically when you are using the 64-bit version and require the 32-bit version. To resolve this error, download the 32-bit version of Java Development Kit.

"keytool error: java.security.KeyStoreException: PKCS11 not found"

You will encounter this error if:
- your config file is not properly configured. Check that your config file is pointing to the correct directory (e.g. library=c:\WINDOWS\system32\eTPKCS11.dll). 
- your token's device drivers are not installed on your computer. You would have been prompted to install the SafeNet Authentication Client upon picking up and installing your certificate. You may attempt to run the installation again to properly install the Client. If you are unable to install the client please contact support for further assistance.


"jarsigner error: java.lang.RuntimeException: keystore load: load failed"

You will encounter this error if you entered the wrong password.

If you have any questions or concerns please contact the Entrust Certificate Services Support department for further assistance: 

Hours of Operation:
Sunday 8:00 PM ET to Friday 8:00 PM ET 
North America (toll free): 1-866-267-9297 
Outside North America: 1-613-270-2680 (or see the list below) 
NOTE: It is very important that international callers dial the UITF format exactly as indicated. Do not dial an extra "1" before the "800" or your call will not be accepted as an UITF toll free call.

CountryNumber
Australia0011 - 800-3687-7863
1-800-767-513
Austria00 - 800-3687-7863
Belgium00 - 800-3687-7863
Denmark00 - 800-3687-7863
Finland990 - 800-3687-7863 (Telecom Finland)
00 - 800-3687-7863 (Finnet)
France00 - 800-3687-7863
Germany00 - 800-3687-7863
Hong Kong001 - 800-3687-7863 (Voice)
002 - 800-3687-7863 (Fax)
Ireland00 - 800-3687-7863
Israel014 - 800-3687-7863
Italy00 - 800-3687-7863
Japan001 - 800-3687-7863 (KDD)
004 - 800-3687-7863 (ITJ)
0061 - 800-3687-7863 (IDC)
Korea001 - 800-3687-7863 (Korea Telecom)
002 - 800-3687-7863 (Dacom)
Malaysia00 - 800-3687-7863
Netherlands00 - 800-3687-7863
New Zealand00 - 800-3687-7863
0800-4413101
Norway00 - 800-3687-7863
Singapore001 - 800-3687-7863
Spain00 - 800-3687-7863
Sweden00 - 800-3687-7863 (Telia)
00 - 800-3687-7863 (Tele2)
Switzerland00 - 800-3687-7863
Taiwan00 - 800-3687-7863
United Kingdom00 - 800-3687-7863
0800 121 6078
+44 (0) 118 953 3088