The Java Archive (JAR) format is used to package Java applications and libraries. SignServer signs JAR files using the JArchive Signer, which embeds a CMS signature directly into the archive. Signed JAR files can optionally include a timestamp from a TSA using the RFC 3161 format.
JArchive Signer Configuration Properties
The following properties are most relevant when configuring the JArchive Signer:
|
Property |
Description |
|---|---|
|
|
Algorithm for the digest of the file entries and the manifest. Example: |
|
|
Set to |
|
|
Set to |
|
|
The algorithm used to sign the data. Example: |
|
|
The source of the signature name. Example: |
|
|
URL of an external TSA to use for timestamping. Example: |
|
|
Worker ID or name of an internal timestamp Signer within the same SignServer instance. Example: |
|
|
Set to |
For all available properties, see JArchive Signer.
Set up the JAR Signer
Step 1 – Add and Configure the Signer
-
Click Add, and select From Template.
-
Choose jarchive_signer.properties, and click Next.
-
Click Apply.
-
Select the Worker named JArchiveSigner in the list.
-
Click the Configuration tab and update the following properties:
-
NAME: Set a descriptive name for the worker.
-
CRYPTOTOKEN: set this to match your Crypto Token.
-
-
Click the Status Summary tab, and click Renew Key.
-
Select a Key Algorithm (for example,
RSA) and Key Specification (for example,2048), and click Generate.
Step 2 - Generate a CSR and Install the Certificate
-
Choose a Signature Algorithm, for example,
SHA256withRSA, and enter a Subject DN for the certificate, for example,CN=JAR Signer Test,O=My Company,C=SE. -
Click Generate.
-
Click Download and save the CSR file.
-
Submit the CSR to your Certificate Authority. The CA returns the signed certificate and any CA certificates in the chain.
Before installing certificates in a production system, verify the authorization settings of the Signer. Once certificates are installed, the Signer is fully active and ready to accept signing requests.
-
Click Install certificates. Provide the Signer certificate first, then add the issuing CA certificates in order. Click Add for each certificate to append it to the chain.
-
When all certificates are in the correct order, click Install.
-
Confirm the Worker status is Active. If not, check the Status Summary page for errors.
Sign a JAR File
You can submit files for signing using the Client Web, the SignClient, or HTTP clients like cURL.
You can download a sample JAR to test with: helloworld.jar
Using Client Web
-
Go to the SignServer Client Web Generic page.
-
Scroll down to the Generic Signing Or Validation by File Upload section and specify your Worker name, for example
JArchiveSigner, in the Worker Name field. -
Click Choose File, select your JAR file, for example,
helloworld.jar. -
Click Submit.
-
Save the returned signed JAR file.
Using SignClient
Send a signing request using the SignServer SignClient:
bin/signclient signdocument -workername JArchiveSigner -infile helloworld.jar -outfile helloworldsigned.jar
Where workername is your Worker name, infile is the path to the unsigned JAR, and outfile is where the signed JAR will be written.
Using cURL
Replace http://localhost:8080/ with the address of your server or appliance:
curl -F "workerName=JArchiveSigner" -F "file=@helloworld.jar" \
http://localhost:8080/signserver/process > helloworld-signed.jar
Verify the Signature
Use the jarsigner tool, included in the Java Development Kit (JDK), to verify a signed JAR file.
After installing the JDK, execute the command as a user, with the path to the signed file:
jarsigner -verify -strict helloworld-signed.jar
To also display the signing certificates and additional details, add the -verbose -certs options:
jarsigner -verify -strict -verbose -certs helloworld-signed.jar