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.
Prerequisites
- An Infisical project with a signer configured
- An active signing grant for the signer
- A machine identity with Universal Auth and
Signpermission on the signer - The Infisical PKCS#11 module installed and configured
- Java JDK 9 or later (for the
-addproviderflag)
Step 1: Create the SunPKCS11 Provider Configuration
Create a configuration file for Java’s SunPKCS11 provider. Save it asinfisical-pkcs11.cfg:
On macOS, use the
.dylib extension. On Windows, use .dll.slot parameter:
Step 2: Sign a JAR
Usejarsigner with the PKCS#11 provider to sign your JAR file:
-keystore NONE: Required when using PKCS#11 (no file-based keystore).-storetype PKCS11: Tells jarsigner to use the PKCS#11 provider.-sigalg: Must match the signer’s key type. UseSHA256withRSAfor RSA keys orSHA256withECDSAfor EC keys.- The last argument (
release-signer) is the signer name (the token label in PKCS#11).
clientId:clientSecret.
Verify the Signature
After signing, verify the JAR signature:CI/CD Integration
For automated signing in CI/CD pipelines, use environment variables for credentials and suppress the password prompt:- Use
-storepass ""to avoid the interactive password prompt in non-interactive environments. - Ensure your machine identity has an active signing grant before the build starts. You can automate grant requests via the Infisical API.
Troubleshooting
For any issue, start by enabling debug logging in your config file to get detailed output:CKR_GENERAL_ERROR when signing
CKR_GENERAL_ERROR when signing
This typically means the signing request was denied by the server. Check that you have an active signing grant for the signer. You can verify this in the Infisical UI under Code Signing > Approvals > Grants.
No slots visible or authentication errors
No slots visible or authentication errors
Verify that your credentials and
project_id are correct, and that the machine identity has been added to the project with the appropriate permissions.