Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
Add code signing docs
Carlos Monastyrskie7863469ed48
diff --git a/docs/docs.json b/docs/docs.jsonindex 9d78284cc7..35cf16b9e7 100644--- a/docs/docs.json+++ b/docs/docs.json@@ -783,6 +783,26 @@"documentation/platform/pki/ca/azure-adcs","documentation/platform/pki/ca/aws-pca"]+ },+ {+ "group": "Code Signing",+ "pages": [+ "documentation/platform/pki/code-signing/overview",+ "documentation/platform/pki/code-signing/signers",+ "documentation/platform/pki/code-signing/approvals",+ "documentation/platform/pki/code-signing/pkcs11-module",+ {+ "group": "Guides",+ "pages": [+ "documentation/platform/pki/code-signing/guides/pkcs11-jarsigner",+ "documentation/platform/pki/code-signing/guides/pkcs11-osslsigncode",+ "documentation/platform/pki/code-signing/guides/pkcs11-apksigner",+ "documentation/platform/pki/code-signing/guides/pkcs11-cosign",+ "documentation/platform/pki/code-signing/guides/pkcs11-openssl",+ "documentation/platform/pki/code-signing/guides/pkcs11-gpg"+ ]+ }+ ]}]},diff --git a/docs/documentation/platform/pki/code-signing/approvals.mdx b/docs/documentation/platform/pki/code-signing/approvals.mdxnew file mode 100644index 0000000000..ef25769895--- /dev/null+++ b/docs/documentation/platform/pki/code-signing/approvals.mdx@@ -0,0 +1,216 @@+---+title: "Approval Policies & Grants"+sidebarTitle: "Approvals"+description: "Learn how to configure approval workflows for code signing operations."+---++In Infisical, code signing approval workflows add a human review step before signing operations can be performed, helping organizations enforce separation of duties and maintain compliance for software supply chain security.++## When to Use Approval Workflows++Approval workflows are recommended when:++- **Separation of duties is required**: Your organization requires different people to request and authorize code signing.+- **Release signing needs oversight**: Signing production releases, firmware, or customer-facing artifacts requires additional review.+- **Compliance mandates review**: Regulatory frameworks or internal policies require documented approval before signing.+- **Preventing unauthorized signing**: You want to ensure artifacts are only signed after proper validation.++## Approval Modes++Infisical supports three approval modes that control how signing grants are issued:++### Manual++Each approved request grants exactly **one signing operation**. This is the strictest mode. Every artifact signature requires a separate approval.++This mode is recommended for high-security environments where each signing operation must be individually authorized.++### Time Window++Each approved request grants signing access for a **defined time period**. You can sign unlimited times within the window.++This mode is recommended for release cycles where a team needs to sign multiple artifacts during a release window (e.g., a 4-hour release deployment).++<Note>+ - The policy defines a `maxWindowDuration` that constrains how long a window can be (from 1 minute to 30 days).+ - The requester specifies the desired `windowStart` and `windowEnd` within that constraint.+</Note>++### N-Signings++Each approved request grants a **fixed number of signing operations**. Once the quota is exhausted, the grant expires automatically.++This mode is recommended for CI pipelines that need to sign a known number of artifacts per build (e.g., 10 JARs per release).++<Note>+ The policy defines a `maxSignings` that caps the number of signings a requester can ask for.+</Note>++## Approval Policies++An approval policy defines the workflow that must be completed before signing access is granted for a specific signer. Every [signer](/documentation/platform/pki/code-signing/signers) must be linked to an approval policy.++Key features of approval policies include:++- **Approval mode selection**: Choose between Manual, Time Window, or N-Signings mode.+- **Multi-step workflows**: Configure sequential approval steps where each step must be completed before the next begins.+- **Flexible approvers**: Assign individual users or groups as eligible approvers for each step.+- **Required approval count**: Specify how many approvals are needed per step (e.g., require 2 out of 5 eligible approvers).+- **Request expiration**: Set a maximum time-to-live (TTL) for pending requests.++### Guide to Creating an Approval Policy++To create an approval policy, head to your Certificate Management Project > **Code Signing > Approvals > Policies** and press **Create Policy**.++<Steps>+ <Step title="Configuring the policy">+ Configure the basic policy settings:++ - **Policy Name**: A descriptive name for the policy such as `release-signing-approval`.+ - **Approval Mode**: The mode that fits your workflow:+ - **Manual**: One approval = one signature.+ - **Time Window**: Approval grants access for a time period. Configure the **Max. Window Duration** (e.g., `4h`, `1d`).+ - **N-Signings**: Approval grants a fixed quota. Configure the **Max. Signings** count.+ - **Max. Request TTL**: The maximum time a request can remain pending before it expires (optional).+ - **Bypass approval for machine identities**: When enabled, machine identities can sign without requiring approval.++ + </Step>+ <Step title="Configuring the approval sequence">+ Configure the approval steps. Each step defines who can approve and how many approvals are required:++ - **Step Name**: An optional name for the step such as `Security Team Review`.+ - **Approvers**: The individual users or groups who are eligible to approve this step.+ - **Required Approvals**: The number of approvals needed to complete this step.++ You can add multiple steps to create a sequential approval workflow. For example:+ 1. **Team Lead Review**: Requires 1 approval from the team leads group+ 2. **Security Review**: Requires 2 approvals from the security team++ Each step must be completed in order before the signing grant is issued.++ + </Step>+ <Step title="Reviewing and creating the policy">+ Review your policy configuration and press **Create** to save the policy.++ + </Step>+</Steps>++## Requesting Signing Access++When a user or machine identity needs to sign artifacts, they must first request signing access through the approval workflow.++### Guide to Requesting Access++Head to your Certificate Management Project > **Code Signing > Approvals > Requests** and press **Request Signing Access**.++++<Steps>+ <Step title="Selecting a signer and configuring parameters">+ Select the signer you want to use. The form will automatically load the approval mode associated with that signer's policy.++ Depending on the approval mode, provide the required parameters:++ - **Manual**: No additional parameters needed.+ - **Time Window**: Specify the **Window Start** and **Window End** for when you need signing access.+ - **N-Signings**: Specify the **Number of Signings** you need.+ - **Justification**: Optionally provide a reason for the request (e.g., "Release v2.4.0 signing").++ + </Step>+ <Step title="Submitting the request">+ Press **Submit** to create the request. Eligible approvers will be notified.+ </Step>+</Steps>++## Approval Requests++When a signing access request is submitted, an approval request is created. Approvers can then review and approve or reject the request.++### Viewing Requests++Head to **Code Signing > Approvals > Requests** to view all approval requests. You can filter requests by status:++- **Open**: Requests currently pending approval+- **Approved**: Requests that have been approved and grants issued+- **Rejected**: Requests that were rejected by an approver+- **Cancelled**: Requests cancelled by the requester+- **Expired**: Requests that exceeded their maximum TTL++### Approving a Request++<Steps>+ <Step title="Opening the request">+ Press on a pending request to view its details.++ + </Step>+ <Step title="Reviewing the request details">+ Review the signing access request information including:+ - Requester name+ - Signer name and certificate+ - Approval mode and parameters (time window, signing count, etc.)+ - Justification+ </Step>+ <Step title="Approve or add comments">+ If you are an eligible approver for the current step, press **Approve** to approve the request.+ </Step>+</Steps>++Once all required approvals for all steps are obtained, a signing grant is automatically issued and the requester can begin signing.++### Rejecting a Request++<Steps>+ <Step title="Opening the request">+ Press on a pending request to view its details.+ </Step>+ <Step title="Rejecting with reason">+ If you are an eligible approver for the current step, press **Reject** to reject the request. Optionally add a comment explaining the rejection.+ </Step>+</Steps>++When a request is rejected, no signing grant is issued.++## Grants++A grant is the authorization that allows a user or machine identity to perform signing operations with a specific signer. Grants are automatically created when an approval request is fully approved.++### Viewing Grants++Head to **Code Signing > Approvals > Grants** to view all grants. You can filter by status:++- **Active**: Grants that are currently valid and can be used for signing.+- **Expired**: Grants that have expired (time window ended, signing quota exhausted, or TTL reached).+- **Revoked**: Grants that were manually revoked by an administrator.++++### Revoking a Grant++Administrators can revoke an active grant at any time. To revoke a grant, press the **Revoke** action on the grant row and optionally provide a reason.++Once revoked, the grant can no longer be used for signing operations. The user must request a new grant through the approval workflow.++## FAQ++<AccordionGroup>+ <Accordion title="I approved a request but the grant wasn't issued">+ If the approval policy has multiple steps, your approval may have completed only one step. The grant is issued only after all approval steps are completed. Check the request details to see which step is currently pending.+ </Accordion>+ <Accordion title="My grant expired before I finished signing">+ Depending on the approval mode:+ - **Time Window**: Your window end time has passed. Request a new grant with a longer window.+ - **N-Signings**: You used all your allotted signings. Request a new grant with a higher count.+ - **Manual**: Manual grants are single-use. Request a new grant for each signing operation.+ </Accordion>+ <Accordion title="Can I extend an active grant?">+ Grants cannot be extended. You need to create a new approval request for additional signing access.+ </Accordion>+ <Accordion title="What happens to in-flight signing operations when a grant is revoked?">+ If a signing operation is already being processed when the grant is revoked, the operation will complete. Subsequent signing attempts with the revoked grant will be denied.+ </Accordion>+</AccordionGroup>diff --git a/docs/documentation/platform/pki/code-signing/guides/pkcs11-apksigner.mdx b/docs/documentation/platform/pki/code-signing/guides/pkcs11-apksigner.mdxnew file mode 100644index 0000000000..9cfedd76f3--- /dev/null+++ b/docs/documentation/platform/pki/code-signing/guides/pkcs11-apksigner.mdx@@ -0,0 +1,124 @@+---+title: "Sign Android APKs with apksigner"+sidebarTitle: "apksigner"+description: "Use the Infisical PKCS#11 module to sign Android APK and AAB files with apksigner."+---++In the following steps, we explore how to sign Android APK and Android App Bundle (AAB) files using `apksigner` with the Infisical PKCS#11 module. Since `apksigner` is a Java-based tool, it uses the same SunPKCS11 provider approach as jarsigner.++## Prerequisites++- An Infisical project with a [signer](/documentation/platform/pki/code-signing/signers) configured+- An active [signing grant](/documentation/platform/pki/code-signing/approvals) for the signer+- A [machine identity](/documentation/platform/identities/machine-identities) with Universal Auth and `Sign` permission on the signer+- The Infisical PKCS#11 module [installed and configured](/documentation/platform/pki/code-signing/pkcs11-module)+- Android SDK Build Tools 30.0.0 or later (includes `apksigner`)++## Step 1: Create the SunPKCS11 Provider Configuration++Create a configuration file for Java's SunPKCS11 provider. Save it as `infisical-pkcs11.cfg`:++```+name = Infisical+library = /usr/local/lib/libinfisical-pkcs11.so+```++<Note>+ On macOS, use `.dylib`. On Windows, use `.dll`. If you have multiple signers and need a specific one, add `slot = 0` (replace with the correct slot index).+</Note>++## Step 2: Sign an APK++Use `apksigner` with the PKCS#11 provider:++```bash+apksigner sign \+ --ks NONE \+ --ks-type PKCS11 \+ --provider-class sun.security.pkcs11.SunPKCS11 \+ --provider-arg infisical-pkcs11.cfg \+ --ks-key-alias "release-signer" \+ --out app-release-signed.apk \+ app-release-unsigned.apk+```++<Note>+ - `--ks NONE`: Required when using PKCS#11 (no file-based keystore).+ - `--ks-type PKCS11`: Tells apksigner to use the PKCS#11 provider.+ - `--ks-key-alias`: The signer name (token label in PKCS#11).+ - `--out`: Writes the signed APK to a new file. Without this flag, `apksigner` modifies the APK **in place**.+</Note>++When prompted for a keystore password, press Enter (the module authenticates using the credentials from your environment variables or config file).++### Signing an Android App Bundle (AAB)++For AAB files, use `jarsigner` instead of `apksigner` since AAB signing follows the JAR signing format:++```bash+jarsigner \+ -keystore NONE \+ -storetype PKCS11 \+ -addprovider SunPKCS11 \+ -providerArg infisical-pkcs11.cfg \+ -sigalg SHA256withRSA \+ app-release.aab \+ "release-signer"+```++## Step 3: Verify the Signature++Verify the signed APK. If you signed in place (without `--out`), verify the same file. If you used `--out`, verify the output file:++```bash+apksigner verify --verbose app-release-signed.apk+```++The output confirms the APK signature is valid:++```+Verifies+Verified using v1 scheme (JAR signing): true+Verified using v2 scheme (APK Signature Scheme v2): true+Verified using v3 scheme (APK Signature Scheme v3): true+```++## CI/CD Integration++Example for a Gradle-based Android project in CI:++```bash+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"++# Build unsigned APK+./gradlew assembleRelease++# Sign with Infisical+apksigner sign \+ --ks NONE \+ --ks-type PKCS11 \+ --provider-class sun.security.pkcs11.SunPKCS11 \+ --provider-arg infisical-pkcs11.cfg \+ --ks-key-alias "release-signer" \+ --ks-pass pass:"" \+ --out app-release-signed.apk \+ app/build/outputs/apk/release/app-release-unsigned.apk++# Verify+apksigner verify --verbose app-release-signed.apk+```++## Troubleshooting++For any issue, enable debug logging in your config file (`"log_level": "debug"`, `"log_file": "/tmp/infisical-pkcs11.log"`) to get detailed output.++<AccordionGroup>+ <Accordion title="Failed to load signer or key alias not found">+ Ensure the `--provider-class` is `sun.security.pkcs11.SunPKCS11`, the `--provider-arg` points to a valid config file, and the `--ks-key-alias` matches your signer name exactly.+ </Accordion>+ <Accordion title="APK signature scheme v2/v3 not applied">+ Use `apksigner` (not `jarsigner`) for APK signing. Only `apksigner` applies v2/v3 APK signature schemes.+ </Accordion>+</AccordionGroup>diff --git a/docs/documentation/platform/pki/code-signing/guides/pkcs11-cosign.mdx b/docs/documentation/platform/pki/code-signing/guides/pkcs11-cosign.mdxnew file mode 100644index 0000000000..c74c34d6ad--- /dev/null+++ b/docs/documentation/platform/pki/code-signing/guides/pkcs11-cosign.mdx@@ -0,0 +1,169 @@+---+title: "Sign Container Images with cosign"+sidebarTitle: "cosign"+description: "Use the Infisical PKCS#11 module to sign OCI container images with Sigstore cosign."+---++In the following steps, we explore how to sign OCI container images using `cosign` (from the Sigstore project) with the Infisical PKCS#11 module. Container image signing is a critical part of securing software supply chains. It lets you verify that images in your registry were built by trusted pipelines.++## Prerequisites++- An Infisical project with a [signer](/documentation/platform/pki/code-signing/signers) configured+- An active [signing grant](/documentation/platform/pki/code-signing/approvals) for the signer+- A [machine identity](/documentation/platform/identities/machine-identities) with Universal Auth and `Sign` permission on the signer+- The Infisical PKCS#11 module [installed and configured](/documentation/platform/pki/code-signing/pkcs11-module)+- `cosign` v2.0 or later, **built with PKCS#11 support** (see below)+- Write access to an OCI-compatible container registry++## Step 1: Install cosign with PKCS#11 Support++<Warning>+ Pre-built cosign binaries (including Homebrew) do **not** include PKCS#11 support. You must build cosign from source with the `pkcs11key` build tag enabled.+</Warning>++<Tabs>+ <Tab title="Go install (recommended)">+ ```bash+ CGO_ENABLED=1 go install -tags pkcs11key github.com/sigstore/cosign/v2/cmd/cosign@latest+ ```+ </Tab>+ <Tab title="Build from source">+ ```bash+ git clone https://github.com/sigstore/cosign.git+ cd cosign+ CGO_ENABLED=1 go build -tags pkcs11key -o cosign ./cmd/cosign+ sudo mv cosign /usr/local/bin/+ ```+ </Tab>+</Tabs>++Verify PKCS#11 support is available:++```bash+cosign pkcs11-tool --help+```++If you see `This cosign was not built with pkcs11-tool support!`, you need to rebuild with the `pkcs11key` tag.++## Step 2: Sign a Container Image++First, list the available tokens and key URIs to find the correct PKCS#11 URI for your signer:++```bash+cosign pkcs11-tool list-tokens \+ --module-path /usr/local/lib/libinfisical-pkcs11.so++cosign pkcs11-tool list-keys-uris \+ --module-path /usr/local/lib/libinfisical-pkcs11.so \+ --slot-id 0+```++Sign an image in your registry using the PKCS#11 key:++```bash+export COSIGN_PKCS11_MODULE_PATH="/usr/local/lib/libinfisical-pkcs11.so"++cosign sign \+ --key "pkcs11:token=release-signer;object=release-signer;type=private" \+ --tlog-upload=false \+ myregistry.example.com/myapp@sha256:abc123...+```++<Note>+ - The `--key` flag uses a PKCS#11 URI. The `token` must match your signer's token label and `object` must match the key label. Use `cosign pkcs11-tool list-keys-uris` to find the exact URI.+ - Set `COSIGN_PKCS11_MODULE_PATH` to the absolute path of the Infisical PKCS#11 shared library.+ - Use `--tlog-upload=false` if you are not using a Sigstore transparency log.+ - cosign pushes the signature to the same registry alongside the image.+ - You may need to authenticate to your container registry first (e.g., `docker login` or `cosign login`).+ - Prefer signing by digest (`@sha256:...`) rather than tag for reproducible builds.+</Note>++## Step 3: Verify the Signature++Verify a signed image using the public key or certificate from the signer:++```bash+# Extract the certificate and public key from PKCS#11+pkcs11-tool --module /usr/local/lib/libinfisical-pkcs11.so \+ --slot 0 --read-object --type cert --label release-signer \+ --output-file signer-cert.der+openssl x509 -inform DER -in signer-cert.der -pubkey -noout > pubkey.pem++# Verify with cosign+cosign verify \+ --key pubkey.pem \+ --insecure-ignore-tlog \+ myregistry.example.com/myapp:v1.0.0+```++<Note>+ Use `--insecure-ignore-tlog` if you signed without uploading to a transparency log. In production, configure a transparency log for auditability.+</Note>++## CI/CD Integration++Example for a container build pipeline:++```bash+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"+export COSIGN_PKCS11_MODULE_PATH="/usr/local/lib/libinfisical-pkcs11.so"++# Build and push the image+docker build -t myregistry.example.com/myapp:${CI_COMMIT_TAG} .+docker push myregistry.example.com/myapp:${CI_COMMIT_TAG}++# Get the image digest+DIGEST=$(docker inspect --format='{{index .RepoDigests 0}}' myregistry.example.com/myapp:${CI_COMMIT_TAG})++# Sign the image by digest+cosign sign \+ --key "pkcs11:token=release-signer;object=release-signer;type=private" \+ --tlog-upload=false \+ "${DIGEST}"+```++### Kubernetes Admission Control++Combine cosign verification with a Kubernetes admission controller (e.g., [Kyverno](https://kyverno.io/) or [Connaisseur](https://github.com/sse-secure-systems/connaisseur)) to enforce that only signed images are deployed:++```yaml+# Kyverno example policy+apiVersion: kyverno.io/v1+kind: ClusterPolicy+metadata:+ name: verify-image-signatures+spec:+ validationFailureAction: Enforce+ rules:+ - name: check-image-signature+ match:+ any:+ - resources:+ kinds:+ - Pod+ verifyImages:+ - imageReferences:+ - "myregistry.example.com/myapp:*"+ attestors:+ - entries:+ - keys:+ publicKeys: |-+ -----BEGIN PUBLIC KEY-----+ <your-signer-public-key>+ -----END PUBLIC KEY-----+```++## Troubleshooting++For any issue, enable debug logging in your config file (`"log_level": "debug"`, `"log_file": "/tmp/infisical-pkcs11.log"`) to get detailed output.++<AccordionGroup>+ <Accordion title="'unimplemented' or 'not built with pkcs11-tool support'">+ Your cosign binary was not built with PKCS#11 support. Pre-built binaries (including Homebrew) do not include it. Rebuild from source with `CGO_ENABLED=1 go install -tags pkcs11key github.com/sigstore/cosign/v2/cmd/cosign@latest`.+ </Accordion>+ <Accordion title="Error getting signer or key not found">+ Ensure the PKCS#11 URI includes both `token` and `object` fields matching your signer name, and that `COSIGN_PKCS11_MODULE_PATH` is set to the absolute path of the module. Use `cosign pkcs11-tool list-keys-uris` to find the correct URI.+ </Accordion>+</AccordionGroup>diff --git a/docs/documentation/platform/pki/code-signing/guides/pkcs11-gpg.mdx b/docs/documentation/platform/pki/code-signing/guides/pkcs11-gpg.mdxnew file mode 100644index 0000000000..3ce587e4b7--- /dev/null+++ b/docs/documentation/platform/pki/code-signing/guides/pkcs11-gpg.mdx@@ -0,0 +1,217 @@+---+title: "Sign Git Commits and Tags with GPG"+sidebarTitle: "GPG"+description: "Use the Infisical PKCS#11 module with GnuPG to sign git commits, tags, and packages."+---++In the following steps, we explore how to use GnuPG with the Infisical PKCS#11 module via `gnupg-pkcs11-scd`. This enables signing git commits and tags, RPM/DEB packages, and any other artifact that uses GPG signatures, all backed by keys stored securely in Infisical.++## Prerequisites++- An Infisical project with a [signer](/documentation/platform/pki/code-signing/signers) configured (RSA keys recommended for GPG compatibility)+- An active [signing grant](/documentation/platform/pki/code-signing/approvals) for the signer+- A [machine identity](/documentation/platform/identities/machine-identities) with Universal Auth and `Sign` permission on the signer+- The Infisical PKCS#11 module [installed and configured](/documentation/platform/pki/code-signing/pkcs11-module)+- GnuPG 2.2 or later+- `gnupg-pkcs11-scd` (the PKCS#11 smart card daemon bridge)++## Step 1: Install gnupg-pkcs11-scd++<Tabs>+ <Tab title="Ubuntu / Debian">+ ```bash+ sudo apt-get update+ sudo apt-get install -y gnupg2 gnupg-pkcs11-scd opensc+ ```+ </Tab>+ <Tab title="macOS (Homebrew)">+ ```bash+ brew install gnupg gnupg-pkcs11-scd opensc+ ```+ </Tab>+ <Tab title="RHEL / Fedora">+ ```bash+ sudo dnf install gnupg2 gnupg-pkcs11-scd opensc+ ```+ </Tab>+</Tabs>++## Step 2: Configure gnupg-pkcs11-scd++Create `~/.gnupg/gnupg-pkcs11-scd.conf`:++```+providers infisical+provider-infisical-library /usr/local/lib/libinfisical-pkcs11.so+```++<Note>+ On macOS, use the `.dylib` extension: `provider-infisical-library /usr/local/lib/libinfisical-pkcs11.dylib`+</Note>++Configure GnuPG to use the PKCS#11 smart card daemon. Edit `~/.gnupg/gpg-agent.conf`:++```+scdaemon-program /usr/bin/gnupg-pkcs11-scd+```++<Note>+ The path to `gnupg-pkcs11-scd` varies by platform. On macOS with Homebrew, use `/opt/homebrew/bin/gnupg-pkcs11-scd`. Run `which gnupg-pkcs11-scd` to find the correct path.+</Note>++Restart the GPG agent to apply the changes:++```bash+gpgconf --kill gpg-agent+```++## Step 3: Import the PKCS#11 Key into GPG++List the available keys from the PKCS#11 token:++```bash+gpg --card-status+```++The output shows your signer's key information. To use the key for signing, you need to learn the key grip and create a GPG key stub:++```bash+# List key grips from the PKCS#11 token+gpg-connect-agent "SCD LEARN" /bye+```++Look for lines starting with `KEY-FRIEDNLY` or `KEYPAIRINFO`. These show the available keys and their key grips (40-character hex strings). Note the key grip for the signer you want to use.++<Warning>+ If multiple signers use the same certificate/key, they will share the same key grip. GPG will attempt to sign using the first matching slot. Ensure the signer in the first slot has an active signing grant, or configure your project so each key is used by only one signer.+</Warning>++Then generate a key stub:++You can generate the key stub interactively:++```bash+gpg --expert --full-gen-key+# Select option: (13) Existing key+# Enter the key grip from the previous step+```++Or use batch mode for CI/CD environments:++```bash+cat > /tmp/gpg-keygen.txt <<EOF+Key-Type: RSA+Key-Length: 3072+Key-Grip: <KEY-GRIP-FROM-PREVIOUS-STEP>+Name-Real: Release Signing+Name-Email: [email protected]+Expire-Date: 0+%no-protection+%commit+EOF++gpg --batch --gen-key /tmp/gpg-keygen.txt+```++Note the key ID from the output (shown as a 40-character hex string). You'll use it for signing.++## Step 4: Sign Git Commits++Configure git to use your GPG key:++```bash+# Set the signing key+git config --global user.signingkey <KEY-ID>++# Enable commit signing by default+git config --global commit.gpgsign true++# Enable tag signing by default+git config --global tag.gpgsign true+```++Now every commit and tag will be signed automatically:++```bash+# Signed commit+git commit -m "feat: add new feature"++# Signed tag+git tag -s v1.0.0 -m "Release v1.0.0"+```++### Verify Signatures++```bash+# Verify a commit signature+git log --show-signature -1++# Verify a tag signature+git tag -v v1.0.0+```++## Step 5: Sign Arbitrary Files++Use GPG to create detached signatures for any file:++```bash+# Create a detached signature+gpg --detach-sign --armor -u <KEY-ID> release-v1.0.0.tar.gz++# Verify+gpg --verify release-v1.0.0.tar.gz.asc release-v1.0.0.tar.gz+```++## CI/CD Integration++For CI pipelines, configure the GPG agent in non-interactive mode. You need to create the key stub on each run since `GNUPGHOME` is ephemeral:++```bash+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"++# Set up ephemeral GPG home directory+export GNUPGHOME=$(mktemp -d)+cp /path/to/gnupg-pkcs11-scd.conf "$GNUPGHOME/"+cp /path/to/gpg-agent.conf "$GNUPGHOME/"++# Discover available keys from the PKCS#11 token+gpg-connect-agent "SCD LEARN" /bye++# Create a key stub pointing to the PKCS#11 key+# Replace KEY-GRIP with the grip from the SCD LEARN output (KEYPAIRINFO line)+cat > /tmp/gpg-keygen.txt <<EOF+Key-Type: RSA+Key-Length: 3072+Key-Grip: <KEY-GRIP>+Name-Real: CI Signing+Name-Email: [email protected]+Expire-Date: 0+%no-protection+%commit+EOF+gpg --batch --gen-key /tmp/gpg-keygen.txt++# Sign the artifact using the generated key+gpg --detach-sign --armor artifact.tar.gz+```++<Note>+ - The `Key-Length` in the batch keygen must match your signer's key size (e.g., 2048, 3072, or 4096 for RSA).+ - The Infisical auth environment variables must be set before the GPG agent starts, as the agent inherits the environment when `gpg-connect-agent` launches it.+ - For repeated CI runs, you can hardcode the key grip value since it doesn't change for a given signer.+</Note>++## Troubleshooting++For any issue, enable debug logging in your config file (`"log_level": "debug"`, `"log_file": "/tmp/infisical-pkcs11.log"`) to get detailed output.++<AccordionGroup>+ <Accordion title="Card error or signing failures">+ Ensure `gnupg-pkcs11-scd` is installed and the path in `gpg-agent.conf` is correct. If the key stub is missing, run `gpg --card-status` to refresh, then `gpg -K` to verify. Restart the agent with `gpgconf --kill gpg-agent` if needed.+ </Accordion>+ <Accordion title="ECDSA keys not working">+ GPG has limited ECDSA curve support via PKCS#11. RSA keys (2048, 3072, 4096) are recommended for GPG signing.+ </Accordion>+</AccordionGroup>diff --git a/docs/documentation/platform/pki/code-signing/guides/pkcs11-jarsigner.mdx b/docs/documentation/platform/pki/code-signing/guides/pkcs11-jarsigner.mdxnew file mode 100644index 0000000000..fa25f2ef3a--- /dev/null+++ b/docs/documentation/platform/pki/code-signing/guides/pkcs11-jarsigner.mdx@@ -0,0 +1,119 @@+---+title: "Sign JARs with jarsigner"+sidebarTitle: "jarsigner"+description: "Use the Infisical PKCS#11 module to sign Java artifacts with jarsigner."+---++In the following steps, we explore how to 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. Private keys never leave the server.++## Prerequisites++- An Infisical project with a [signer](/documentation/platform/pki/code-signing/signers) configured+- An active [signing grant](/documentation/platform/pki/code-signing/approvals) for the signer+- A [machine identity](/documentation/platform/identities/machine-identities) with Universal Auth and `Sign` permission on the signer+- The Infisical PKCS#11 module [installed and configured](/documentation/platform/pki/code-signing/pkcs11-module)+- Java JDK 9 or later (for the `-addprovider` flag)++## Step 1: Create the SunPKCS11 Provider Configuration++Create a configuration file for Java's SunPKCS11 provider. Save it as `infisical-pkcs11.cfg`:++```+name = Infisical+library = /usr/local/lib/libinfisical-pkcs11.so+```++<Note>+ On macOS, use the `.dylib` extension. On Windows, use `.dll`.+</Note>++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+```++## Step 2: Sign a JAR++Use `jarsigner` with the PKCS#11 provider to sign your JAR file:++```bash+jarsigner \+ -keystore NONE \+ -storetype PKCS11 \+ -addprovider SunPKCS11 \+ -providerArg infisical-pkcs11.cfg \+ -sigalg SHA256withRSA \+ myapp.jar \+ "release-signer"+```++<Note>+ - `-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. Use `SHA256withRSA` for RSA keys or `SHA256withECDSA` for EC keys.+ - The last argument (`release-signer`) is the **signer name** (the token label in PKCS#11).+</Note>++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`.++### Verify the Signature++After signing, verify the JAR signature:++```bash+jarsigner -verify -verbose myapp.jar+```++The output indicates the JAR is signed and verified:++```+jar verified.+```++## CI/CD Integration++For automated signing in CI/CD pipelines, use environment variables for credentials and suppress the password prompt:++```bash+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"+```++<Note>+ - 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.+</Note>++## Troubleshooting++For any issue, start by enabling debug logging in your config file to get detailed output:++```json+{+ "log_level": "debug",+ "log_file": "/tmp/infisical-pkcs11.log"+}+```++<AccordionGroup>+ <Accordion title="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**.+ </Accordion>+ <Accordion title="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.+ </Accordion>+</AccordionGroup>diff --git a/docs/documentation/platform/pki/code-signing/guides/pkcs11-openssl.mdx b/docs/documentation/platform/pki/code-signing/guides/pkcs11-openssl.mdxnew file mode 100644index 0000000000..77a11d4f56--- /dev/null+++ b/docs/documentation/platform/pki/code-signing/guides/pkcs11-openssl.mdx@@ -0,0 +1,199 @@+---+title: "Sign with OpenSSL"+sidebarTitle: "OpenSSL"+description: "Use the Infisical PKCS#11 module with OpenSSL's pkcs11 engine for general-purpose signing."+---++In the following steps, we explore how to use OpenSSL with the Infisical PKCS#11 module via the `libp11` engine. OpenSSL is a versatile foundation for signing any file format. It is useful when you need raw signatures, custom signing pipelines, or integration with tools that wrap OpenSSL.++## Prerequisites++- An Infisical project with a [signer](/documentation/platform/pki/code-signing/signers) configured+- An active [signing grant](/documentation/platform/pki/code-signing/approvals) for the signer+- A [machine identity](/documentation/platform/identities/machine-identities) with Universal Auth and `Sign` permission on the signer+- The Infisical PKCS#11 module [installed and configured](/documentation/platform/pki/code-signing/pkcs11-module)+- OpenSSL 1.1.1 or later+- `libp11` (OpenSSL PKCS#11 engine)++## Step 1: Install the PKCS#11 Engine++<Tabs>+ <Tab title="Ubuntu / Debian">+ ```bash+ sudo apt-get update+ sudo apt-get install -y opensc libengine-pkcs11-openssl+ ```+ </Tab>+ <Tab title="macOS (Homebrew)">+ ```bash+ brew install opensc libp11+ ```+ </Tab>+ <Tab title="RHEL / Fedora">+ ```bash+ sudo dnf install opensc p11-kit engine-pkcs11+ ```+ </Tab>+</Tabs>++Verify the engine is available:++```bash+openssl engine pkcs11 -t+```++The output confirms the engine is loaded:++```+(pkcs11) pkcs11 engine+ [ available ]+```++## Step 2: Create an OpenSSL Configuration++Create an OpenSSL config file `infisical-openssl.cnf` to set up the PKCS#11 engine:++```ini+openssl_conf = openssl_init++[openssl_init]+engines = engine_section++[engine_section]+pkcs11 = pkcs11_section++[pkcs11_section]+engine_id = pkcs11+MODULE_PATH = /usr/local/lib/libinfisical-pkcs11.so+init = 0+```++Set this as the active OpenSSL config:++```bash+export OPENSSL_CONF=/path/to/infisical-openssl.cnf+```++## Step 3: Sign a File++Sign a file using the PKCS#11 key. The same command works for both RSA and ECDSA keys. OpenSSL automatically selects the correct algorithm based on the key type:++```bash+openssl dgst -sha256 \+ -engine pkcs11 \+ -keyform engine \+ -sign "pkcs11:object=release-signer;type=private" \+ -out document.sig \+ document.txt+```++<Note>+ - The `object` in the PKCS#11 URI must match your signer name exactly.+ - The output is a raw signature file (PKCS#1 for RSA, DER-encoded for ECDSA).+</Note>++### Sign with RSA-PSS Padding++For RSA keys, you can use PSS padding instead of the default PKCS#1 v1.5:++```bash+openssl dgst -sha256 \+ -engine pkcs11 \+ -keyform engine \+ -sign "pkcs11:object=release-signer;type=private" \+ -sigopt rsa_padding_mode:pss \+ -sigopt rsa_pss_saltlen:32 \+ -out document.sig \+ document.txt+```++<Note>+ RSA-PSS requires the signer's key to support the `RSASSA_PSS` mechanism. This is only available with RSA keys.+</Note>++## Step 4: Verify the Signature++Extract the public key or certificate from PKCS#11, then verify:++```bash+# Extract the certificate and public key+pkcs11-tool --module /usr/local/lib/libinfisical-pkcs11.so \+ --slot 0 --read-object --type cert --label release-signer \+ --output-file cert.der+openssl x509 -inform DER -in cert.der -pubkey -noout > pubkey.pem++# Verify the signature+openssl dgst -sha256 \+ -verify pubkey.pem \+ -signature document.sig \+ document.txt+```++The output confirms the signature is valid:++```+Verified OK+```++## Common Use Cases++### Sign a Checksum Manifest++```bash+# Generate checksums+sha256sum *.tar.gz > SHA256SUMS++# Sign the manifest+openssl dgst -sha256 \+ -engine pkcs11 \+ -keyform engine \+ -sign "pkcs11:object=release-signer;type=private" \+ -out SHA256SUMS.sig \+ SHA256SUMS+```++### Create a Detached S/MIME Signature++```bash+openssl cms -sign \+ -engine pkcs11 \+ -keyform engine \+ -inkey "pkcs11:object=release-signer;type=private" \+ -signer signer-cert.pem \+ -in document.pdf \+ -out document.pdf.p7s \+ -outform DER \+ -binary+```++## CI/CD Integration++```bash+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"+export OPENSSL_CONF="/path/to/infisical-openssl.cnf"++# Sign release artifacts+for file in dist/*.tar.gz; do+ openssl dgst -sha256 \+ -engine pkcs11 \+ -keyform engine \+ -sign "pkcs11:object=release-signer;type=private" \+ -out "${file}.sig" \+ "${file}"+done+```++## Troubleshooting++For any issue, enable debug logging in your config file (`"log_level": "debug"`, `"log_file": "/tmp/infisical-pkcs11.log"`) to get detailed output.++<AccordionGroup>+ <Accordion title="Engine 'pkcs11' not found or key errors">+ Ensure `libp11` is installed and the object name in the PKCS#11 URI matches your signer name exactly. Check the engine is registered with `openssl engine -t pkcs11`.+ </Accordion>+ <Accordion title="OpenSSL 3.0+ deprecation warnings">+ OpenSSL 3.0 deprecated engines in favor of providers. The `libp11` engine still works but may show warnings. For a provider-based approach, use [`pkcs11-provider`](https://github.com/latchset/pkcs11-provider) instead.+ </Accordion>+</AccordionGroup>diff --git a/docs/documentation/platform/pki/code-signing/guides/pkcs11-osslsigncode.mdx b/docs/documentation/platform/pki/code-signing/guides/pkcs11-osslsigncode.mdxnew file mode 100644index 0000000000..cfe39f6494--- /dev/null+++ b/docs/documentation/platform/pki/code-signing/guides/pkcs11-osslsigncode.mdx@@ -0,0 +1,139 @@+---+title: "Sign Windows Executables with osslsigncode"+sidebarTitle: "osslsigncode"+description: "Use the Infisical PKCS#11 module to sign Windows executables, DLLs, and MSI installers with osslsigncode."+---++In the following steps, we explore how to sign Windows Authenticode artifacts using `osslsigncode` with the Infisical PKCS#11 module. osslsigncode is a cross-platform tool that lets you sign Windows binaries from Linux and macOS, making it ideal for CI/CD pipelines that don't run on Windows.++## Prerequisites++- An Infisical project with a [signer](/documentation/platform/pki/code-signing/signers) configured+- An active [signing grant](/documentation/platform/pki/code-signing/approvals) for the signer+- A [machine identity](/documentation/platform/identities/machine-identities) with Universal Auth and `Sign` permission on the signer+- The Infisical PKCS#11 module [installed and configured](/documentation/platform/pki/code-signing/pkcs11-module)+- `osslsigncode` 2.5 or later (includes native PKCS#11 support)++## Step 1: Install osslsigncode and Dependencies++<Tabs>+ <Tab title="Ubuntu / Debian">+ ```bash+ sudo apt-get update+ sudo apt-get install -y osslsigncode opensc+ ```+ </Tab>+ <Tab title="macOS (Homebrew)">+ ```bash+ brew install osslsigncode opensc+ ```+ </Tab>+ <Tab title="Build from source">+ ```bash+ git clone https://github.com/mtrojnar/osslsigncode.git+ cd osslsigncode+ mkdir build && cd build+ cmake ..+ make+ sudo make install+ ```+ </Tab>+</Tabs>++## Step 2: Identify Your Signer++Use `pkcs11-tool` to list available signers and note the token label:++```bash+pkcs11-tool --module /usr/local/lib/libinfisical-pkcs11.so --list-slots+```++```+Available slots:+Slot 0 (0x0): release-signer+ token label : release-signer+ token manufacturer : Infisical+```++## Step 3: Sign a Windows Executable++Use `osslsigncode` with the PKCS#11 module to sign your binary:++```bash+osslsigncode sign \+ -pkcs11module /usr/local/lib/libinfisical-pkcs11.so \+ -pkcs11cert "pkcs11:object=release-signer;type=cert" \+ -key "pkcs11:object=release-signer;type=private" \+ -h sha256 \+ -n "My Application" \+ -i "https://example.com" \+ -t http://timestamp.digicert.com \+ -in MyApp.exe \+ -out MyApp-signed.exe+```++<Note>+ - `-pkcs11module`: Path to the Infisical PKCS#11 shared library.+ - `-pkcs11cert` and `-key`: PKCS#11 URI referencing your signer by name. Replace `release-signer` with your signer name.+ - `-h sha256`: Hash algorithm for the signature digest.+ - `-n`: Description embedded in the signature (shown in Windows UAC prompts).+ - `-i`: URL for more information about the publisher.+ - `-t`: Timestamp server URL. Timestamping ensures the signature remains valid after your certificate expires.+</Note>++### Supported File Types++osslsigncode can sign the following Windows artifact types:++| Type | Extensions |+|------|-----------|+| Executables | `.exe`, `.dll`, `.sys`, `.ocx` |+| Installers | `.msi`, `.msix`, `.appx` |+| Cabinet files | `.cab` |+| Scripts | `.ps1`, `.vbs` |+| Catalogs | `.cat` |++## Step 4: Verify the Signature++Verify the signed binary:++```bash+osslsigncode verify MyApp-signed.exe+```++The output confirms the signature is valid:++```+Signature verification: ok+```++## CI/CD Integration++```bash+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"++osslsigncode sign \+ -pkcs11module /usr/local/lib/libinfisical-pkcs11.so \+ -pkcs11cert "pkcs11:object=release-signer;type=cert" \+ -key "pkcs11:object=release-signer;type=private" \+ -h sha256 \+ -n "My Application" \+ -t http://timestamp.digicert.com \+ -in MyApp.exe \+ -out MyApp-signed.exe+```++## Troubleshooting++For any issue, enable debug logging in your config file (`"log_level": "debug"`, `"log_file": "/tmp/infisical-pkcs11.log"`) to get detailed output.++<AccordionGroup>+ <Accordion title="Key not found or signing errors">+ Verify the object name in the PKCS#11 URI matches your signer name exactly and that you have an active signing grant. You can list available signers with `pkcs11-tool --module /path/to/lib --list-slots`.+ </Accordion>+ <Accordion title="Certificate not found in PKCS#11">+ The `-pkcs11cert` URI must match your signer name exactly. Use `pkcs11-tool --module /path/to/lib --list-objects --type cert` to verify available certificate labels.+ </Accordion>+</AccordionGroup>diff --git a/docs/documentation/platform/pki/code-signing/overview.mdx b/docs/documentation/platform/pki/code-signing/overview.mdxnew file mode 100644index 0000000000..1d2c161744--- /dev/null+++ b/docs/documentation/platform/pki/code-signing/overview.mdx@@ -0,0 +1,70 @@+---+title: "Code Signing"+sidebarTitle: "Overview"+description: "Securely sign code and artifacts with centralized key management and approval workflows."+---++In Infisical, Code Signing lets you digitally sign software artifacts (JARs, binaries, container images, and more) while keeping private keys secure on the server. Instead of distributing signing keys to developer workstations or CI pipelines, signing operations are performed centrally through Infisical with full audit trails and approval controls.++## How It Works++<div align="center">++```mermaid+sequenceDiagram+ participant Tool as Signing Tool+ participant PKCS as PKCS#11 Module+ participant API as Infisical API+ participant KMS as Key Storage++ Tool->>PKCS: Sign data+ PKCS->>API: POST /signers/{id}/sign+ API->>API: Validate grant & policy+ API->>KMS: Retrieve private key+ KMS-->>API: Private key+ API->>API: Compute signature+ API-->>PKCS: Signature bytes+ PKCS-->>Tool: Signature+```++</div>++1. A **Signer** is created and bound to a certificate with the `codeSigning` extended key usage.+2. An **Approval Policy** governs who can use the signer and under what conditions.+3. Users or machine identities **request signing access** through the approval workflow.+4. Once approved, the caller receives a **grant** that authorizes signing operations.+5. The signing tool (e.g., jarsigner) calls the Infisical API, either directly or through the [PKCS#11 module](/documentation/platform/pki/code-signing/pkcs11-module), and the signature is computed server-side.+6. Every signing operation is recorded as an immutable **audit entry** on the signer.++## Core Concepts++### Signers++A [signer](/documentation/platform/pki/code-signing/signers) is a named code-signing identity bound to a certificate. It represents a signing capability within a project. Signers hold no private key material locally. All cryptographic operations happen on the Infisical server.++### Approval Policies++[Approval policies](/documentation/platform/pki/code-signing/approvals) define the rules that must be satisfied before signing can occur. Infisical supports three approval modes:++- **Manual**: Each approval grants exactly one signing operation.+- **Time Window**: Approval grants signing access for a defined time period.+- **N-Signings**: Approval grants a fixed number of signing operations.++### Signing Operations++Every call to sign data, whether it succeeds, fails, or is denied, is recorded as a signing operation. This provides a complete audit trail of who signed what, when, and using which grant.++### PKCS#11 Module++The Infisical [PKCS#11 module](/documentation/platform/pki/code-signing/pkcs11-module) implements the PKCS#11 v2.40 standard, allowing standard signing tools to use Infisical signers without code changes. The module supports RSA (PKCS#1 v1.5 and PSS) and ECDSA signing mechanisms.++## Getting Started++<CardGroup cols={2}>+ <Card title="Create a Signer" href="/documentation/platform/pki/code-signing/signers">+ Set up a code-signing identity and bind it to a certificate.+ </Card>+ <Card title="Configure Approvals" href="/documentation/platform/pki/code-signing/approvals">+ Define approval policies to control who can sign and when.+ </Card>+</CardGroup>diff --git a/docs/documentation/platform/pki/code-signing/pkcs11-module.mdx b/docs/documentation/platform/pki/code-signing/pkcs11-module.mdxnew file mode 100644index 0000000000..0c5ed4742b--- /dev/null+++ b/docs/documentation/platform/pki/code-signing/pkcs11-module.mdx@@ -0,0 +1,147 @@+---+title: "PKCS#11 Module"+sidebarTitle: "PKCS#11 Module"+description: "Install and configure the Infisical PKCS#11 module for use with standard signing tools."+---++The Infisical PKCS#11 module implements the PKCS#11 v2.40 standard, allowing tools like `jarsigner`, `openssl`, `cosign`, `osslsigncode`, `apksigner`, and `gpg` to use Infisical signers without code changes. Private keys never leave the server.++## Installation++Download the pre-built binary for your platform from the [releases page](https://github.com/Infisical/infisical-pkcs-11/releases):++| Platform | File |+|----------|------|+| Linux x86_64 | `libinfisical-pkcs11.so` |+| Linux ARM64 | `libinfisical-pkcs11.so` |+| macOS x86_64 | `libinfisical-pkcs11.dylib` |+| macOS ARM64 | `libinfisical-pkcs11.dylib` |+| Windows x86_64 | `libinfisical-pkcs11.dll` |++Place the binary in a known location, for example `/usr/local/lib/`:++```bash+# Linux+sudo cp libinfisical-pkcs11.so /usr/local/lib/+sudo chmod 755 /usr/local/lib/libinfisical-pkcs11.so++# macOS+sudo cp libinfisical-pkcs11.dylib /usr/local/lib/+sudo chmod 755 /usr/local/lib/libinfisical-pkcs11.dylib+```++### Building from Source++If you prefer to build from source, you need Go 1.24+ and a C compiler:++```bash+git clone https://github.com/Infisical/infisical-pkcs-11.git+cd infisical-pkcs-11+make build+```++The output binary will be in the current directory.++## Configuration++Create a JSON configuration file at `/etc/infisical/pkcs11.conf` (or any path you prefer):++```json+{+ "server_url": "https://app.infisical.com",+ "project_id": "<your-project-id>",+ "log_level": "info"+}+```++Then set the authentication credentials via environment variables:++```bash+export INFISICAL_UNIVERSAL_AUTH_CLIENT_ID="<your-machine-identity-client-id>"+export INFISICAL_UNIVERSAL_AUTH_CLIENT_SECRET="<your-machine-identity-client-secret>"+```++<Note>+ Credentials can also be placed in the config file under `auth.client_id` and `auth.client_secret`, but we recommend using environment variables to prevent secrets from being committed to version control or exposed in file system backups.+</Note>++If using a non-default config path, set:++```bash+export INFISICAL_PKCS11_CONFIG=/path/to/your/pkcs11.conf+```++### Configuration Reference++| Field | Required | Default | Description |+|-------|----------|---------|-------------|+| `server_url` | Yes | None | Infisical server URL |+| `project_id` | Yes | None | Project ID containing the signers |+| `auth.method` | No | `universal-auth` | Authentication method |+| `auth.client_id` | No | None | Machine identity client ID (prefer env var) |+| `auth.client_secret` | No | None | Machine identity client secret (prefer env var) |+| `tls.ca_cert_path` | No | None | Custom CA cert for self-hosted instances |+| `tls.skip_verify` | No | `false` | Skip TLS verification (development only) |+| `cache.token_ttl_seconds` | No | `300` | Auth token cache duration |+| `cache.cert_ttl_seconds` | No | `3600` | Certificate data cache duration |+| `cache.signer_ttl_seconds` | No | `300` | Signer list cache duration |+| `log_level` | No | `info` | Log level: `trace`, `debug`, `info`, `warn`, `error` |+| `log_file` | No | stderr | Path to log file |++### Environment Variable Reference++| Variable | Description |+|----------|-------------|+| `INFISICAL_UNIVERSAL_AUTH_CLIENT_ID` | Machine identity client ID |+| `INFISICAL_UNIVERSAL_AUTH_CLIENT_SECRET` | Machine identity client secret |+| `INFISICAL_PKCS11_SERVER_URL` | Override `server_url` from config |+| `INFISICAL_PKCS11_CONFIG` | Path to config file (default: `/etc/infisical/pkcs11.conf`) |++<Note>+ Environment variables always take precedence over values in the configuration file.+</Note>++## Verifying the Module++Use `pkcs11-tool` (from OpenSC) to verify the module is working:++```bash+# List available slots (one per signer)+pkcs11-tool --module /usr/local/lib/libinfisical-pkcs11.so --list-slots+```++The output lists one slot per signer in your project:++```+Available slots:+Slot 0 (0x0): release-signer+ token label : release-signer+ token manufacturer : Infisical+ ...+```++To list the objects (private key, certificate, public key) in a slot:++```bash+pkcs11-tool --module /usr/local/lib/libinfisical-pkcs11.so --slot 0 --list-objects+```++## Troubleshooting++For any issue, start by enabling debug logging in your config file to get detailed output:++```json+{+ "log_level": "debug",+ "log_file": "/tmp/infisical-pkcs11.log"+}+```++<AccordionGroup>+ <Accordion title="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.+ </Accordion>+ <Accordion title="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**.+ </Accordion>+</AccordionGroup>diff --git a/docs/documentation/platform/pki/code-signing/signers.mdx b/docs/documentation/platform/pki/code-signing/signers.mdxnew file mode 100644index 0000000000..b099dad365--- /dev/null+++ b/docs/documentation/platform/pki/code-signing/signers.mdx@@ -0,0 +1,137 @@+---+title: "Signers"+sidebarTitle: "Signers"+description: "Learn how to create and manage code-signing identities."+---++In Infisical, a signer is a named code-signing identity bound to an X.509 certificate with the `codeSigning` extended key usage (EKU). Each signer represents a signing capability within a project, for example `release-signer` for production releases or `ci-signer` for CI pipeline artifacts.++Private keys never leave the Infisical server. When a signing operation is requested, the server retrieves the key, computes the signature, and returns only the signature bytes. This ensures that signing keys cannot be exfiltrated from build environments.++## Key Characteristics++- **Bound to a certificate**: Every signer must be linked to a certificate that has the `codeSigning` EKU.+- **Linked to an approval policy**: Every signer must be associated with an [approval policy](/documentation/platform/pki/code-signing/approvals) that governs who can sign and under what conditions.+- **Supports RSA and ECDSA**: Signers support RSA (2048, 3072, 4096-bit) and ECDSA (P-256, P-384, P-521) key types depending on the certificate.+- **Tracks signing history**: Every signing operation is recorded with actor, algorithm, data hash, and grant information.++## Guide to Creating a Signer++<Steps>+ <Step title="Issuing a code-signing certificate">+ Before creating a signer, you need a certificate with the `codeSigning` extended key usage. You can issue one from your Certificate Authority (CA) by specifying `codeSigning` in the extended key usage field.++ <Note>+ Only certificates with the `codeSigning` extended key usage will be available when creating a signer. If you don't see your certificate, verify that it was issued with the correct EKU.+ </Note>+ </Step>+ <Step title="Creating an approval policy">+ Every signer requires an approval policy. If you haven't created one yet, head to **Code Signing > Approvals > Policies** and press **Create Policy**. See [Approval Policies](/documentation/platform/pki/code-signing/approvals) for details.+ </Step>+ <Step title="Creating the signer">+ Head to your Certificate Management Project > **Code Signing > Signers** and press **Create Signer**.++ ++ Fill in the following fields:++ - **Name**: A slug-friendly name for the signer such as `release-signer`.+ - **Description**: An optional description of the signer's purpose.+ - **Certificate**: The code-signing certificate to bind to this signer.+ - **Approval Policy**: The approval policy that governs signing access for this signer.++ Press **Create** to save the signer.+ </Step>+</Steps>++## Managing Signers++### Viewing Signer Details++Press on any signer in the table to view its detail page, which includes:++- **Overview**: Signer name, status, linked certificate details (serial number, algorithm, validity dates), and the associated approval policy.+- **Signing Operations**: A paginated audit log of all signing operations performed with this signer, including status, algorithm, actor, and timestamp.++++### Signing Operations Log++The signer detail page includes a complete audit trail of all signing activity, including successful signatures, denied requests, and errors. Each entry shows the timestamp, algorithm, data hash, and the actor that performed the operation.++### Enabling and Disabling Signers++Signers can be toggled between **Active** and **Disabled** states. A disabled signer will reject all signing requests until re-enabled. To toggle the status, use the status switch on the signer detail page or the signer table.++++### Deleting a Signer++To delete a signer, press the delete action on the signer table row. Deleting a signer does not delete the underlying certificate or its signing operation history.++<Warning>+ Deleting a signer is irreversible. Any active grants for the signer will no longer be usable.+</Warning>++## Supported Signing Algorithms++The available signing algorithms depend on the certificate's key type:++### RSA++| Algorithm | Description |+|-----------|-------------|+| `RSASSA_PKCS1_V1_5_SHA256` | RSA PKCS#1 v1.5 with SHA-256 |+| `RSASSA_PKCS1_V1_5_SHA384` | RSA PKCS#1 v1.5 with SHA-384 |+| `RSASSA_PKCS1_V1_5_SHA512` | RSA PKCS#1 v1.5 with SHA-512 |+| `RSASSA_PSS_SHA256` | RSA-PSS with SHA-256 |+| `RSASSA_PSS_SHA384` | RSA-PSS with SHA-384 |+| `RSASSA_PSS_SHA512` | RSA-PSS with SHA-512 |++### ECDSA++| Algorithm | Description |+|-----------|-------------|+| `ECDSA_SHA256` | ECDSA with SHA-256 |+| `ECDSA_SHA384` | ECDSA with SHA-384 |+| `ECDSA_SHA512` | ECDSA with SHA-512 |++## Signing via API++You can also sign data programmatically by making an API request to the Sign endpoint:++```bash+curl --request POST \+ --url https://app.infisical.com/api/v1/pki/signers/{signerId}/sign \+ --header 'Authorization: Bearer <access-token>' \+ --header 'Content-Type: application/json' \+ --data '{+ "data": "<base64-encoded-data>",+ "signingAlgorithm": "RSASSA_PKCS1_V1_5_SHA256",+ "isDigest": true,+ "clientMetadata": {+ "tool": "custom-pipeline",+ "hostname": "build-server-1"+ }+ }'+```++<Note>+ - The `data` field must be base64-encoded and no larger than 128 bytes (the digest of what you want to sign).+ - Set `isDigest` to `true` if the data is already a hash digest, or `false` if you want the server to hash it.+ - The `clientMetadata` field is optional and recorded in the signing operation audit log.+</Note>++## FAQ++<AccordionGroup>+ <Accordion title="Can I use the same certificate for multiple signers?">+ Yes. Multiple signers can reference the same certificate, each with a different approval policy. This is useful if you want different approval workflows for different teams using the same signing key.+ </Accordion>+ <Accordion title="What happens if my certificate expires?">+ Signing requests will be rejected if the signer's certificate has expired. You should issue a new certificate and update the signer's certificate binding before expiry.+ </Accordion>+ <Accordion title="Can machine identities sign without human approval?">+ Yes, depending on the approval policy configuration. If the policy allows machine identity bypass or uses automatic approval modes, machine identities can sign without human intervention after obtaining a grant.+ </Accordion>+</AccordionGroup>diff --git a/docs/documentation/platform/pki/overview.mdx b/docs/documentation/platform/pki/overview.mdxindex af6a13530d..80b310a695 100644--- a/docs/documentation/platform/pki/overview.mdx+++ b/docs/documentation/platform/pki/overview.mdx@@ -18,3 +18,4 @@ Core capabilities include:- [Certificate Syncs](/documentation/platform/pki/certificate-syncs/overview): Push certificates to cloud certificate managers like [AWS Certificate Manager](/documentation/platform/pki/certificate-syncs/aws-certificate-manager) and [Azure Key Vault](/documentation/platform/pki/certificate-syncs/azure-key-vault).- [Certificate Discovery](/documentation/platform/pki/discovery/overview): Discover and map certificates deployed across your infrastructure, providing full visibility into your organization's certificate landscape.- [Certificate Alerts](/documentation/platform/pki/alerting/overview): Receive alerts and webhook events for certificate lifecycle changes such as certificate expiration.+- [Code Signing](/documentation/platform/pki/code-signing/overview): Digitally sign software artifacts with centralized key management, approval workflows, and PKCS#11 integration for tools like jarsigner.diff --git a/docs/images/platform/pki/code-signing/approval-policies.png b/docs/images/platform/pki/code-signing/approval-policies.pngnew file mode 100644index 0000000000..0c04a9c262Binary files /dev/null and b/docs/images/platform/pki/code-signing/approval-policies.png differdiff --git a/docs/images/platform/pki/code-signing/approval-policy-create.png b/docs/images/platform/pki/code-signing/approval-policy-create.pngnew file mode 100644index 0000000000..f9266afe46Binary files /dev/null and b/docs/images/platform/pki/code-signing/approval-policy-create.png differdiff --git a/docs/images/platform/pki/code-signing/approval-policy-review.png b/docs/images/platform/pki/code-signing/approval-policy-review.pngnew file mode 100644index 0000000000..5bbe8ed557Binary files /dev/null and b/docs/images/platform/pki/code-signing/approval-policy-review.png differdiff --git a/docs/images/platform/pki/code-signing/approval-policy-steps.png b/docs/images/platform/pki/code-signing/approval-policy-steps.pngnew file mode 100644index 0000000000..748ab35917Binary files /dev/null and b/docs/images/platform/pki/code-signing/approval-policy-steps.png differdiff --git a/docs/images/platform/pki/code-signing/approval-request-detail.png b/docs/images/platform/pki/code-signing/approval-request-detail.pngnew file mode 100644index 0000000000..c170623b9fBinary files /dev/null and b/docs/images/platform/pki/code-signing/approval-request-detail.png differdiff --git a/docs/images/platform/pki/code-signing/approval-requests.png b/docs/images/platform/pki/code-signing/approval-requests.pngnew file mode 100644index 0000000000..a819c86841Binary files /dev/null and b/docs/images/platform/pki/code-signing/approval-requests.png differdiff --git a/docs/images/platform/pki/code-signing/grants.png b/docs/images/platform/pki/code-signing/grants.pngnew file mode 100644index 0000000000..60c87fa5b2Binary files /dev/null and b/docs/images/platform/pki/code-signing/grants.png differdiff --git a/docs/images/platform/pki/code-signing/request-access-params.png b/docs/images/platform/pki/code-signing/request-access-params.pngnew file mode 100644index 0000000000..5f1079c5a9Binary files /dev/null and b/docs/images/platform/pki/code-signing/request-access-params.png differdiff --git a/docs/images/platform/pki/code-signing/signer-create.png b/docs/images/platform/pki/code-signing/signer-create.pngnew file mode 100644index 0000000000..92259905dfBinary files /dev/null and b/docs/images/platform/pki/code-signing/signer-create.png differdiff --git a/docs/images/platform/pki/code-signing/signer-detail.png b/docs/images/platform/pki/code-signing/signer-detail.pngnew file mode 100644index 0000000000..a41c827212Binary files /dev/null and b/docs/images/platform/pki/code-signing/signer-detail.png differdiff --git a/docs/images/platform/pki/code-signing/signers-table.png b/docs/images/platform/pki/code-signing/signers-table.pngnew file mode 100644index 0000000000..6448704e61Binary files /dev/null and b/docs/images/platform/pki/code-signing/signers-table.png differ