docs/documentation/platform/pki/guides/code-signing/jarsigner.mdx
Sign Java JAR files using jarsigner with the Infisical PKCS#11 module. The module implements the PKCS#11 v2.40 standard, allowing standard signing tools to use Infisical signers without code changes.
-addprovider flag)Configure the Infisical PKCS#11 module with your machine identity credentials. Without this, the signing commands below fail with an auth error.
Create /etc/infisical/pkcs11.conf (or set INFISICAL_PKCS11_CONFIG to point elsewhere):
auth:
method: universal-auth
universal_auth:
client_id: "<machine-identity-client-id>"
client_secret: "<machine-identity-client-secret>"
signer:
id: "<signer-id>"
You can also pass the credentials via environment variables:
export INFISICAL_UNIVERSAL_AUTH_CLIENT_ID="<machine-identity-client-id>"
export INFISICAL_UNIVERSAL_AUTH_CLIENT_SECRET="<machine-identity-client-secret>"
For the full set of options, see the PKCS#11 module configuration reference.
Create a configuration file for Java's SunPKCS11 provider. Save it as infisical-pkcs11.cfg:
name = Infisical
library = /usr/local/lib/libinfisical-pkcs11.so
If you have multiple signers and want to target a specific one, add the slot parameter:
name = Infisical
library = /usr/local/lib/libinfisical-pkcs11.so
slot = 0
Use jarsigner with the PKCS#11 provider to sign your JAR file:
jarsigner \
-keystore NONE \
-storetype PKCS11 \
-addprovider SunPKCS11 \
-providerArg infisical-pkcs11.cfg \
-sigalg SHA256withRSA \
myapp.jar \
"release-signer"
When prompted for a keystore password, you can either press Enter (the module authenticates automatically using the credentials from your environment variables or config file) or provide the PIN in the format clientId:clientSecret.
After signing, verify the JAR signature:
jarsigner -verify -verbose myapp.jar
The output indicates the JAR is signed and verified:
jar verified.
For automated signing in CI/CD pipelines, use environment variables for credentials and suppress the password prompt:
export INFISICAL_UNIVERSAL_AUTH_CLIENT_ID="${INFISICAL_CLIENT_ID}"
export INFISICAL_UNIVERSAL_AUTH_CLIENT_SECRET="${INFISICAL_CLIENT_SECRET}"
export INFISICAL_PKCS11_CONFIG="/path/to/pkcs11.conf"
jarsigner \
-keystore NONE \
-storetype PKCS11 \
-addprovider SunPKCS11 \
-providerArg infisical-pkcs11.cfg \
-sigalg SHA256withRSA \
-storepass "" \
myapp.jar \
"release-signer"
For any issue, start by enabling debug logging in your config file to get detailed output:
{
"log_level": "debug",
"log_file": "/tmp/infisical-pkcs11.log"
}