diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a213f0e..bd15875 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -31,9 +31,19 @@ jobs: - name: Build and test all modules run: ./gradlew clean build + - name: Sign module + run: ./scripts/sign-module.sh + + - name: Verify signed module + run: | + unzip -l webcompat-build/build/webdev-compat.modl | grep -q "certificates.p7b" + unzip -l webcompat-build/build/webdev-compat.modl | grep -q "signatures.properties" + - name: Upload module artifact uses: actions/upload-artifact@v4 with: name: webdev-compat-module - path: webcompat-build/build/*.modl + path: | + webcompat-build/build/*.modl + !webcompat-build/build/*.unsigned.modl retention-days: 30 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index beb6813..33a72ec 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -34,6 +34,9 @@ jobs: - name: Build and test all modules run: ./gradlew clean build + - name: Sign module + run: ./scripts/sign-module.sh + - name: Get version from gradle.properties id: get_version run: | @@ -41,17 +44,22 @@ jobs: echo "VERSION=$VERSION" >> $GITHUB_ENV echo "Module version: $VERSION" + - name: Verify tag matches module version + if: github.ref_type == 'tag' + run: | + EXPECTED_TAG="v$VERSION" + if [ "$GITHUB_REF_NAME" != "$EXPECTED_TAG" ]; then + echo "Tag $GITHUB_REF_NAME does not match module version $VERSION; expected $EXPECTED_TAG" >&2 + exit 1 + fi + - name: Find .modl file id: find_modl run: | MODL_FILE=$(find webcompat-build/build -name "*.modl" ! -name "*.unsigned.modl" -type f | head -1) - if [ -z "$MODL_FILE" ]; then - MODL_FILE=$(find webcompat-build/build -name "*.unsigned.modl" -type f | head -1) - fi - if [ -z "$MODL_FILE" ]; then - echo "No .modl file found under webcompat-build/build" - exit 1 - fi + test -n "$MODL_FILE" + unzip -l "$MODL_FILE" | grep -q "certificates.p7b" + unzip -l "$MODL_FILE" | grep -q "signatures.properties" echo "MODL_FILE=$MODL_FILE" >> $GITHUB_ENV echo "Found module file: $MODL_FILE" @@ -66,8 +74,9 @@ jobs: Version: ${{ env.VERSION }} ### Installation - 1. Download the .modl file below + 1. Download the signed .modl file below 2. Install it in Ignition via Config > Modules > Install or Upgrade a Module + 3. Accept the self-signed certificate if prompted ### Changes See the commit history for details on changes in this release. diff --git a/.gitignore b/.gitignore index 409d6c6..749501d 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,12 @@ build/ *.iml .idea/ out/ + +# Module signing certificates, keystores, and downloaded signing tools +certs/* +!certs/README.md +*.jks +*.keystore +*.p12 +*.p7b +tools/module-signer/ diff --git a/README.md b/README.md index d051366..40d805d 100644 --- a/README.md +++ b/README.md @@ -69,10 +69,18 @@ From repo root: - `./gradlew test` - `./gradlew build` +- `./scripts/sign-module.sh` Module artifact: -- `webcompat-build/build/webdev-compat.unsigned.modl` +- unsigned intermediate: `webcompat-build/build/webdev-compat.unsigned.modl` +- signed module: `webcompat-build/build/webdev-compat.modl` + +If signing material does not exist yet, `./scripts/sign-module.sh` creates a simple self-signed certificate under `certs/`; those files are ignored by git. Keep the same generated files if you want future builds to use the same certificate, so Ignition users only need to accept that certificate once. + +Verify the module contains the signing payload: + +- `unzip -l webcompat-build/build/webdev-compat.modl | grep -E 'certificates.p7b|signatures.properties'` ## Live smoke test helper diff --git a/RELEASE_CHECKLIST.md b/RELEASE_CHECKLIST.md index a15ed7b..dbdae67 100644 --- a/RELEASE_CHECKLIST.md +++ b/RELEASE_CHECKLIST.md @@ -17,14 +17,13 @@ Use this checklist before creating a public release. - [ ] (Optional) Run targeted smoke test: - `./scripts/smoke_webdev.sh http://localhost:8088 webcompat_live_parity text GET 200` -## 3. Signing Decision +## 3. Signing -- [ ] Decide artifact type for this release: - - Unsigned (default): keep `skipModlSigning=true` - - Signed: run with `-PskipModlSigning=false` plus required signing configuration - [ ] Build release artifact: - - Unsigned: `./gradlew clean build` - - Signed: `./gradlew clean build -PskipModlSigning=false` + - `./gradlew clean build` + - `./scripts/sign-module.sh` +- [ ] Verify signed artifact: + - `unzip -l webcompat-build/build/webdev-compat.modl | grep -E 'certificates.p7b|signatures.properties'` ## 4. Tag and Publish diff --git a/certs/README.md b/certs/README.md new file mode 100644 index 0000000..299a070 --- /dev/null +++ b/certs/README.md @@ -0,0 +1,9 @@ +# Module signing certificates + +Run this from the repository root to create a simple self-signed module signing certificate: + +```bash +./scripts/create-self-signed-module-cert.sh +``` + +The generated keystore, PEM certificate, and PKCS7 chain are ignored by git because they include local signing material. Keep the same generated files if you want future builds to use the same certificate, so Ignition users only need to accept that certificate once. diff --git a/gradle.properties b/gradle.properties index 4089749..67c4f58 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ ignitionVersion=8.3.0 -moduleVersion=1.1.2 +moduleVersion=1.1.3 moduleId=com.jg.ignition.webcompat moduleName=WebDevCompat skipModlSigning=true diff --git a/scripts/create-self-signed-module-cert.sh b/scripts/create-self-signed-module-cert.sh new file mode 100755 index 0000000..6d9b207 --- /dev/null +++ b/scripts/create-self-signed-module-cert.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +set -euo pipefail + +REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" + +SIGNING_DIR="${MODULE_SIGNING_DIR:-$REPO_ROOT/certs}" +KEYSTORE="${MODULE_SIGNING_KEYSTORE:-$SIGNING_DIR/module-signing-keystore.jks}" +CERT_PEM="${MODULE_SIGNING_CERT_PEM:-$SIGNING_DIR/module-signing-cert.pem}" +CERT_CHAIN="${MODULE_SIGNING_CHAIN:-$SIGNING_DIR/module-signing-chain.p7b}" +ALIAS="${MODULE_SIGNING_ALIAS:-ignition-webdev-compat-self-signed}" +PASSWORD="${MODULE_SIGNING_PASSWORD:-ignition-webdev-compat}" +DNAME="${MODULE_SIGNING_DNAME:-CN=Ignition WebDevCompat Module, OU=Ignition WebDevCompat, O=J.Grocott, L=San Francisco, ST=CA, C=US}" +VALIDITY_DAYS="${MODULE_SIGNING_VALIDITY_DAYS:-3650}" + +mkdir -p "$SIGNING_DIR" + +if [ -f "$KEYSTORE" ]; then + echo "Using existing module signing keystore: $KEYSTORE" +else + echo "Creating self-signed module signing keystore: $KEYSTORE" + keytool -genkeypair \ + -alias "$ALIAS" \ + -keyalg RSA \ + -keysize 2048 \ + -validity "$VALIDITY_DAYS" \ + -keystore "$KEYSTORE" \ + -storepass "$PASSWORD" \ + -keypass "$PASSWORD" \ + -dname "$DNAME" \ + -ext KeyUsage=digitalSignature \ + -ext ExtendedKeyUsage=codeSigning +fi + +echo "Exporting PEM certificate: $CERT_PEM" +keytool -exportcert \ + -alias "$ALIAS" \ + -keystore "$KEYSTORE" \ + -storepass "$PASSWORD" \ + -rfc \ + -file "$CERT_PEM" + +if ! command -v openssl >/dev/null 2>&1; then + echo "openssl is required to create the PKCS7 chain file expected by module-signer." >&2 + exit 1 +fi + +echo "Exporting PKCS7 certificate chain: $CERT_CHAIN" +openssl crl2pkcs7 \ + -nocrl \ + -certfile "$CERT_PEM" \ + -out "$CERT_CHAIN" \ + -outform DER + +echo "Self-signed module signing certificate is ready." +echo " Keystore: $KEYSTORE" +echo " Alias: $ALIAS" +echo " Chain: $CERT_CHAIN" diff --git a/scripts/download-module-signer.sh b/scripts/download-module-signer.sh new file mode 100755 index 0000000..37cb30a --- /dev/null +++ b/scripts/download-module-signer.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +set -euo pipefail + +REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" + +VERSION="${MODULE_SIGNER_VERSION:-0.0.1.ia}" +SIGNER_DIR="${MODULE_SIGNER_DIR:-$REPO_ROOT/tools/module-signer}" +SIGNER_JAR="${MODULE_SIGNER_JAR:-$SIGNER_DIR/module-signer-$VERSION-jar-with-dependencies.jar}" +SIGNER_URL="${MODULE_SIGNER_URL:-https://nexus.inductiveautomation.com/repository/inductiveautomation-releases/com/inductiveautomation/ignitionsdk/module-signer/$VERSION/module-signer-$VERSION-jar-with-dependencies.jar}" + +mkdir -p "$SIGNER_DIR" + +if [ ! -f "$SIGNER_JAR" ]; then + echo "Downloading IA module-signer $VERSION..." + curl -fL "$SIGNER_URL" -o "$SIGNER_JAR" +fi + +echo "$SIGNER_JAR" diff --git a/scripts/sign-module.sh b/scripts/sign-module.sh new file mode 100755 index 0000000..83534e6 --- /dev/null +++ b/scripts/sign-module.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash + +set -euo pipefail + +REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" + +KEYSTORE="${MODULE_SIGNING_KEYSTORE:-$REPO_ROOT/certs/module-signing-keystore.jks}" +CERT_CHAIN="${MODULE_SIGNING_CHAIN:-$REPO_ROOT/certs/module-signing-chain.p7b}" +ALIAS="${MODULE_SIGNING_ALIAS:-ignition-webdev-compat-self-signed}" +PASSWORD="${MODULE_SIGNING_PASSWORD:-ignition-webdev-compat}" +MODULE_IN="${MODULE_IN:-$REPO_ROOT/webcompat-build/build/webdev-compat.unsigned.modl}" +MODULE_OUT="${MODULE_OUT:-$REPO_ROOT/webcompat-build/build/webdev-compat.modl}" + +if [ ! -f "$KEYSTORE" ] || [ ! -f "$CERT_CHAIN" ]; then + "$REPO_ROOT/scripts/create-self-signed-module-cert.sh" +fi + +if [ ! -f "$MODULE_IN" ]; then + echo "Missing unsigned module: $MODULE_IN" >&2 + exit 1 +fi + +SIGNER_JAR="$("$REPO_ROOT/scripts/download-module-signer.sh" | tail -n 1)" + +echo "Signing $(basename "$MODULE_IN") -> $(basename "$MODULE_OUT")" +rm -f "$MODULE_OUT" +java -jar "$SIGNER_JAR" \ + -keystore="$KEYSTORE" \ + -keystore-pwd="$PASSWORD" \ + -alias="$ALIAS" \ + -alias-pwd="$PASSWORD" \ + -chain="$CERT_CHAIN" \ + -module-in="$MODULE_IN" \ + -module-out="$MODULE_OUT"