jarsigner:sign

Full name:

org.apache.maven.plugins:maven-jarsigner-plugin:3.1.0:sign

Description:

Signs a project artifact and attachments using jarsigner.

Attributes:

  • Requires a Maven project to be executed.
  • The goal is thread-safe and supports parallel builds.
  • Since version: 1.0.
  • Binds by default to the lifecycle phase: package.

Optional Parameters

Name Type Since Description
<alias> String - See options.
User Property: jarsigner.alias
<archive> File - Archive to process. If set, neither the project artifact nor any attachments or archive sets are processed.
User Property: jarsigner.archive
<archiveDirectory> File 1.1 The base directory to scan for JAR files using Ant-like inclusion/exclusion patterns.
User Property: jarsigner.archiveDirectory
<arguments> String[] - List of additional arguments to append to the jarsigner command line. Each argument should be specified as a separate element. For example, to specify the name of the signed jar, two elements are needed:
  • Alternative using the command line: -Djarsigner.arguments="-signedjar,my-project_signed.jar"
  • Alternative using the Maven POM configuration:
<configuration>
  <arguments>
    <argument>-signedjar</argument>
    <argument>my-project_signed.jar</argument>
  </arguments>
</configuration>

User Property: jarsigner.arguments
<certchain> File 1.5 Location of the extra certificate chain file. See options.
User Property: jarsigner.certchain
<excludeClassifiers> String[] 1.2 A set of artifact classifiers describing the project attachments that should not be processed. This parameter is only relevant if processAttachedArtifacts is true. If empty, no attachments are excluded.
<excludes> String[] 1.1 The Ant-like exclusion patterns used to exclude JAR files from processing. The patterns must be relative to the directory given by the parameter archiveDirectory.
<includeClassifiers> String[] 1.2 A set of artifact classifiers describing the project attachments that should be processed. This parameter is only relevant if processAttachedArtifacts is true. If empty, all attachments are included.
<includes> String[] 1.1 The Ant-like inclusion patterns used to select JAR files to process. The patterns must be relative to the directory given by the parameter archiveDirectory. By default, the pattern **/*.?ar is used.
<keypass> String - See options.
User Property: jarsigner.keypass
<keystore> String - See options.
User Property: jarsigner.keystore
<maxMemory> String - The maximum memory available to the JAR signer, e.g. 256M. See -Xmx for more details.
User Property: jarsigner.maxMemory
<maxRetryDelaySeconds> int 3.1.0 Maximum delay, in seconds, to wait after a failed attempt before re-trying. The delay after a failed attempt follows an exponential backoff strategy, with increasing delay times.
Default: 0
User Property: jarsigner.maxRetryDelaySeconds
<maxTries> int 3.1.0 How many times to try to sign a jar (assuming each previous attempt is a failure). This option may be desirable if any network operations are used during signing, for example using a Time Stamp Authority or network based PKCS11 HSM solution for storing code signing keys. The default value of 1 indicates that no retries should be made.
Default: 1
User Property: jarsigner.maxTries
<processAttachedArtifacts> boolean 1.1 Controls processing of project attachments. If enabled, attached artifacts that are no JAR/ZIP files will be automatically excluded from processing.
Default: true
User Property: jarsigner.processAttachedArtifacts
<processMainArtifact> boolean 1.1 Controls processing of the main artifact produced by the project.
Default: true
User Property: jarsigner.processMainArtifact
<protectedAuthenticationPath> boolean 1.3 Must be set to true if the password must be given via a protected authentication path such as a dedicated PIN reader.
Default: false
User Property: jarsigner.protectedAuthenticationPath
<providerArg> String - See options.
User Property: jarsigner.providerArg
<providerClass> String - See options.
User Property: jarsigner.providerClass
<providerName> String - See options.
User Property: jarsigner.providerName
<removeExistingSignatures> boolean 1.1 Indicates whether existing signatures should be removed from the processed JAR files prior to signing them. If enabled, the resulting JAR will appear as being signed only once.
Default: false
User Property: jarsigner.removeExistingSignatures
<sigfile> String - See options.
User Property: jarsigner.sigfile
<skip> boolean - Set to true to disable the plugin.
Default: false
User Property: jarsigner.skip
<storepass> String - See options.
User Property: jarsigner.storepass
<storetype> String - See options.
User Property: jarsigner.storetype
<threadCount> int 3.1.0 Maximum number of parallel threads to use when signing jar files. Increases performance when signing multiple jar files, especially when network operations are used during signing, for example when using a Time Stamp Authority or network based PKCS11 HSM solution for storing code signing keys. Note: the logging from the signing process will be interleaved, and harder to read, when using many threads.
Default: 1
User Property: jarsigner.threadCount
<tsa> String[] 1.3

URL(s) to Time Stamping Authority (TSA) server(s) to use to timestamp the signing. See options. Separate multiple TSA URLs with comma (without space) or a nested XML tag.

<configuration>
  <tsa>http://timestamp.digicert.com,http://timestamp.globalsign.com/tsa/r6advanced1</tsa>
</configuration>
<configuration>
  <tsa>
    <url>http://timestamp.digicert.com</url>
    <url>http://timestamp.globalsign.com/tsa/r6advanced1</url>
  </tsa>
</configuration>

Usage of multiple TSA servers only makes sense when maxTries is more than 1. A different TSA server will only be used at retries.

Changed to a list since 3.1.0. Single XML element (without comma) is still supported.


User Property: jarsigner.tsa
<tsacert> String[] 1.3

Alias(es) for certificate(s) in the active keystore used to find a TSA URL. From the certificate the X509v3 extension "Subject Information Access" field is examined to find the TSA server URL. See options. Separate multiple aliases with comma (without space) or a nested XML tag.

<configuration>
  <tsacert>alias1,alias2</tsacert>
</configuration>
<configuration>
  <tsacert>
    <alias>alias1</alias>
    <alias>alias2</alias>
  </tsacert>
</configuration>

Should not be used at the same time as the tsa parameter (because jarsigner will typically ignore tsacert, if tsa is set).

Usage of multiple aliases only makes sense when maxTries is more than 1. A different TSA server will only be used at retries.

Changed to a list since 3.1.0. Single XML element (without comma) is still supported.


User Property: jarsigner.tsacert
<tsadigestalg> String 3.1.0 The message digest algorithm to use in the messageImprint that the TSA server will timestamp. A default value (for example SHA-384) will be selected by jarsigner if this parameter is not set. Only available in Java 11 and later. See options.
User Property: jarsigner.tsadigestalg
<tsapolicyid> String[] 3.1.0

OID(s) to send to the TSA server to identify the policy ID the server should use. If not specified TSA server will choose a default policy ID. Each TSA server vendor will typically define their own policy OIDs. See options. Separate multiple OIDs with comma (without space) or a nested XML tag.

<configuration>
  <tsapolicyid>1.3.6.1.4.1.4146.2.3.1.2,2.16.840.1.114412.7.1</tsapolicyid>
</configuration>
<configuration>
  <tsapolicyid>
    <oid>1.3.6.1.4.1.4146.2.3.1.2</oid>
    <oid>2.16.840.1.114412.7.1</oid>
  </tsapolicyid>
</configuration>

If used, the number of OIDs should be the same as the number of elements in tsa or tsacert. The first OID will be used for the first TSA server, the second OID for the second TSA server and so on.


User Property: jarsigner.tsapolicyid
<verbose> boolean - See options.
Default: false
User Property: jarsigner.verbose
<workingDirectory> File 1.3 Location of the working directory.
Default: ${project.basedir}

Parameter Details

<alias>

See options.
  • Type: java.lang.String
  • Required: No
  • User Property: jarsigner.alias

<archive>

Archive to process. If set, neither the project artifact nor any attachments or archive sets are processed.
  • Type: java.io.File
  • Required: No
  • User Property: jarsigner.archive

<archiveDirectory>

The base directory to scan for JAR files using Ant-like inclusion/exclusion patterns.
  • Type: java.io.File
  • Since: 1.1
  • Required: No
  • User Property: jarsigner.archiveDirectory

<arguments>

List of additional arguments to append to the jarsigner command line. Each argument should be specified as a separate element. For example, to specify the name of the signed jar, two elements are needed:
  • Alternative using the command line: -Djarsigner.arguments="-signedjar,my-project_signed.jar"
  • Alternative using the Maven POM configuration:
<configuration>
  <arguments>
    <argument>-signedjar</argument>
    <argument>my-project_signed.jar</argument>
  </arguments>
</configuration>
  • Type: java.lang.String[]
  • Required: No
  • User Property: jarsigner.arguments

<certchain>

Location of the extra certificate chain file. See options.
  • Type: java.io.File
  • Since: 1.5
  • Required: No
  • User Property: jarsigner.certchain

<excludeClassifiers>

A set of artifact classifiers describing the project attachments that should not be processed. This parameter is only relevant if processAttachedArtifacts is true. If empty, no attachments are excluded.
  • Type: java.lang.String[]
  • Since: 1.2
  • Required: No

<excludes>

The Ant-like exclusion patterns used to exclude JAR files from processing. The patterns must be relative to the directory given by the parameter archiveDirectory.
  • Type: java.lang.String[]
  • Since: 1.1
  • Required: No

<includeClassifiers>

A set of artifact classifiers describing the project attachments that should be processed. This parameter is only relevant if processAttachedArtifacts is true. If empty, all attachments are included.
  • Type: java.lang.String[]
  • Since: 1.2
  • Required: No

<includes>

The Ant-like inclusion patterns used to select JAR files to process. The patterns must be relative to the directory given by the parameter archiveDirectory. By default, the pattern **/*.?ar is used.
  • Type: java.lang.String[]
  • Since: 1.1
  • Required: No

<keypass>

See options.
  • Type: java.lang.String
  • Required: No
  • User Property: jarsigner.keypass

<keystore>

See options.
  • Type: java.lang.String
  • Required: No
  • User Property: jarsigner.keystore

<maxMemory>

The maximum memory available to the JAR signer, e.g. 256M. See -Xmx for more details.
  • Type: java.lang.String
  • Required: No
  • User Property: jarsigner.maxMemory

<maxRetryDelaySeconds>

Maximum delay, in seconds, to wait after a failed attempt before re-trying. The delay after a failed attempt follows an exponential backoff strategy, with increasing delay times.
  • Type: int
  • Since: 3.1.0
  • Required: No
  • User Property: jarsigner.maxRetryDelaySeconds
  • Default: 0

<maxTries>

How many times to try to sign a jar (assuming each previous attempt is a failure). This option may be desirable if any network operations are used during signing, for example using a Time Stamp Authority or network based PKCS11 HSM solution for storing code signing keys. The default value of 1 indicates that no retries should be made.
  • Type: int
  • Since: 3.1.0
  • Required: No
  • User Property: jarsigner.maxTries
  • Default: 1

<processAttachedArtifacts>

Controls processing of project attachments. If enabled, attached artifacts that are no JAR/ZIP files will be automatically excluded from processing.
  • Type: boolean
  • Since: 1.1
  • Required: No
  • User Property: jarsigner.processAttachedArtifacts
  • Default: true

<processMainArtifact>

Controls processing of the main artifact produced by the project.
  • Type: boolean
  • Since: 1.1
  • Required: No
  • User Property: jarsigner.processMainArtifact
  • Default: true

<protectedAuthenticationPath>

Must be set to true if the password must be given via a protected authentication path such as a dedicated PIN reader.
  • Type: boolean
  • Since: 1.3
  • Required: No
  • User Property: jarsigner.protectedAuthenticationPath
  • Default: false

<providerArg>

See options.
  • Type: java.lang.String
  • Required: No
  • User Property: jarsigner.providerArg

<providerClass>

See options.
  • Type: java.lang.String
  • Required: No
  • User Property: jarsigner.providerClass

<providerName>

See options.
  • Type: java.lang.String
  • Required: No
  • User Property: jarsigner.providerName

<removeExistingSignatures>

Indicates whether existing signatures should be removed from the processed JAR files prior to signing them. If enabled, the resulting JAR will appear as being signed only once.
  • Type: boolean
  • Since: 1.1
  • Required: No
  • User Property: jarsigner.removeExistingSignatures
  • Default: false

<sigfile>

See options.
  • Type: java.lang.String
  • Required: No
  • User Property: jarsigner.sigfile

<skip>

Set to true to disable the plugin.
  • Type: boolean
  • Required: No
  • User Property: jarsigner.skip
  • Default: false

<storepass>

See options.
  • Type: java.lang.String
  • Required: No
  • User Property: jarsigner.storepass

<storetype>

See options.
  • Type: java.lang.String
  • Required: No
  • User Property: jarsigner.storetype

<threadCount>

Maximum number of parallel threads to use when signing jar files. Increases performance when signing multiple jar files, especially when network operations are used during signing, for example when using a Time Stamp Authority or network based PKCS11 HSM solution for storing code signing keys. Note: the logging from the signing process will be interleaved, and harder to read, when using many threads.
  • Type: int
  • Since: 3.1.0
  • Required: No
  • User Property: jarsigner.threadCount
  • Default: 1

<tsa>

URL(s) to Time Stamping Authority (TSA) server(s) to use to timestamp the signing. See options. Separate multiple TSA URLs with comma (without space) or a nested XML tag.

<configuration>
  <tsa>http://timestamp.digicert.com,http://timestamp.globalsign.com/tsa/r6advanced1</tsa>
</configuration>
<configuration>
  <tsa>
    <url>http://timestamp.digicert.com</url>
    <url>http://timestamp.globalsign.com/tsa/r6advanced1</url>
  </tsa>
</configuration>

Usage of multiple TSA servers only makes sense when maxTries is more than 1. A different TSA server will only be used at retries.

Changed to a list since 3.1.0. Single XML element (without comma) is still supported.

  • Type: java.lang.String[]
  • Since: 1.3
  • Required: No
  • User Property: jarsigner.tsa

<tsacert>

Alias(es) for certificate(s) in the active keystore used to find a TSA URL. From the certificate the X509v3 extension "Subject Information Access" field is examined to find the TSA server URL. See options. Separate multiple aliases with comma (without space) or a nested XML tag.

<configuration>
  <tsacert>alias1,alias2</tsacert>
</configuration>
<configuration>
  <tsacert>
    <alias>alias1</alias>
    <alias>alias2</alias>
  </tsacert>
</configuration>

Should not be used at the same time as the tsa parameter (because jarsigner will typically ignore tsacert, if tsa is set).

Usage of multiple aliases only makes sense when maxTries is more than 1. A different TSA server will only be used at retries.

Changed to a list since 3.1.0. Single XML element (without comma) is still supported.

  • Type: java.lang.String[]
  • Since: 1.3
  • Required: No
  • User Property: jarsigner.tsacert

<tsadigestalg>

The message digest algorithm to use in the messageImprint that the TSA server will timestamp. A default value (for example SHA-384) will be selected by jarsigner if this parameter is not set. Only available in Java 11 and later. See options.
  • Type: java.lang.String
  • Since: 3.1.0
  • Required: No
  • User Property: jarsigner.tsadigestalg

<tsapolicyid>

OID(s) to send to the TSA server to identify the policy ID the server should use. If not specified TSA server will choose a default policy ID. Each TSA server vendor will typically define their own policy OIDs. See options. Separate multiple OIDs with comma (without space) or a nested XML tag.

<configuration>
  <tsapolicyid>1.3.6.1.4.1.4146.2.3.1.2,2.16.840.1.114412.7.1</tsapolicyid>
</configuration>
<configuration>
  <tsapolicyid>
    <oid>1.3.6.1.4.1.4146.2.3.1.2</oid>
    <oid>2.16.840.1.114412.7.1</oid>
  </tsapolicyid>
</configuration>

If used, the number of OIDs should be the same as the number of elements in tsa or tsacert. The first OID will be used for the first TSA server, the second OID for the second TSA server and so on.

  • Type: java.lang.String[]
  • Since: 3.1.0
  • Required: No
  • User Property: jarsigner.tsapolicyid

<verbose>

See options.
  • Type: boolean
  • Required: No
  • User Property: jarsigner.verbose
  • Default: false

<workingDirectory>

Location of the working directory.
  • Type: java.io.File
  • Since: 1.3
  • Required: No
  • Default: ${project.basedir}