My objective is to publish a library on Maven Central, while using a Hardware Security Module (HSM, explanation below) to sign the binary. The documentation I found explains how to use maven-gpg-plugin
, but this requires the plugin to handle the key and its passphrase, whereas in my case the key is inside the HSM, and cannot leave it.
To illustrate what I mean, here is a simplified draft of my Github CI pipeline:
- The
build
job produces the Jar and uploads it for subsequent reuse. - The
sign
job runs on a self-hosted runner, it downloads the previously stored artifact, runs a graphical interface (implemented insign-gui.ps1
) which is responsible for the human-guided process of signing (e.g., the human connects the computer to a secure network, where the HSM is accessible, types the PIN for accessing the key; an alternative process could be to plug a smart-card into a reader and type the PIN, etc.)
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
cache: maven
- name: Build the jar
run: mvn package -DskipTests
- name: Upload jar for subsequent reuse by signer
uses: actions/upload-artifact@v3
with:
name: compiled-jar
path: target/library.jar
sign:
needs: build
runs-on: self-hosted
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: compiled-jar
path: target
- name: Process retrieved files
run: scripts/sign-gui.ps1 -input target/library.jar -output target/signature.asc
In the end I have a library.jar
and signature.asc
(the detached armored GPG signature). The next step is to feed them into Maven Central, but the available tooling seems to be shaped around the "maven-gpg-plugin signs it and takes care of everything" paradigm. I was unable to find a way to tell Maven that it should take the signature produced by an external program, and then go on with the rest of its publishing logic. Is this possible with maven-gpg-plugin
, in principle? If not, what alternatives are there?
Having explored various open source projects, I found many CI pipelines that have the signing keys and the passphrases to them - thus the key isn't really private. If anyone could point me to repositories that take a different approach, I would greatly appreciate it.
Note: an HSM is a physical device designed to securely store keys and perform operations (e.g., sign, encrypt) with them, without exposing the keys themselves. The keys are generated by the device and held internally in a secure way, to prevent one from making copies of them. The reason for this is to avoid incidents in which someone can steal keys and potentially release their own binaries with your signature on them.