Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion .github/actions/setup-certum/action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Connect to Certum cloud signing
description: Verify the SimplySign installer and connect to the configured certificate.
description: Validate unattended credentials, verify the pinned installer and connect to the configured certificate.
inputs:
username:
required: true
Expand All @@ -13,11 +13,22 @@ inputs:
runs:
using: composite
steps:
- name: Validate unattended signing credentials
shell: pwsh
env:
CERTUM_USERNAME: ${{ inputs.username }}
CERTUM_OTP_URI: ${{ inputs.otp-uri }}
CERTUM_KEY_ID: ${{ inputs.thumbprint }}
run: node "${{ github.action_path }}/../../../scripts/validate-certum-configuration.mjs"
- name: Verify SimplySign installer
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
Invoke-WebRequest 'https://files.certum.eu/software/SimplySignDesktop/Windows/9.4.3.90/SimplySignDesktop-9.4.3.90-64-bit-en.msi' -OutFile SimplySignDesktop.msi
$hash = (Get-FileHash -Algorithm SHA256 SimplySignDesktop.msi).Hash
if ($hash -ne 'CE2B38EF0124A574BC08E5558726099CAAC79A7C58B8D3D712F629371FE1BCB7') {
throw 'SimplySign installer SHA-256 does not match the pinned 9.4.3.90 build'
}
$signature = Get-AuthenticodeSignature SimplySignDesktop.msi
if ($signature.Status -ne 'Valid' -or $signature.SignerCertificate.Subject -notmatch 'Asseco Data Systems') {
throw 'SimplySign installer signature or publisher verification failed'
Expand Down
1 change: 1 addition & 0 deletions .github/release-signing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ fingerprint_files:
- .github/workflows/certum-signing-smoke.yml
- .github/actions/setup-certum/action.yml
- scripts/sign-certum.ps1
- scripts/validate-certum-configuration.mjs
- scripts/install-nsis.ps1
- .github/workflows/release-candidate.yml
- .github/workflows/release-promote.yml
Expand Down
21 changes: 12 additions & 9 deletions .github/workflows/certum-signing-smoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,20 @@ jobs:
with:
ref: ${{ github.workflow_sha }}
persist-credentials: false
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1
with:
go-version-file: go.mod
cache: false
node-version-file: .node-version
- name: Check signing configuration
shell: pwsh
env:
CERTUM_USERNAME: ${{ secrets.CERTUM_USERNAME }}
CERTUM_OTP_URI: ${{ secrets.CERTUM_OTP_URI }}
CERTUM_KEY_ID: ${{ secrets.CERTUM_KEY_ID }}
run: |
$ErrorActionPreference = 'Stop'
if ([string]::IsNullOrWhiteSpace($env:CERTUM_USERNAME)) { throw 'Missing CERTUM_USERNAME' }
if ($env:CERTUM_OTP_URI -notmatch '^otpauth://totp/') { throw 'CERTUM_OTP_URI must be a complete TOTP URI' }
if ($env:CERTUM_KEY_ID -notmatch '^[0-9a-fA-F]{40}$') { throw 'CERTUM_KEY_ID must be the 40-character SHA-1 certificate thumbprint' }

run: node scripts/validate-certum-configuration.mjs
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
cache: false
- name: Build open-source signing probes
shell: pwsh
run: |
Expand Down Expand Up @@ -69,3 +67,8 @@ jobs:
./scripts/sign-certum.ps1 -PayloadDirectory payload
./scripts/sign-certum.ps1 -FilePath installer-probe.exe
'Certum x64/ARM64 payload and installer signing, expected signer, trust, and timestamps passed.' >> $env:GITHUB_STEP_SUMMARY

- name: Disconnect from Certum
if: always()
shell: pwsh
run: Get-Process -Name '*SimplySign*' -ErrorAction SilentlyContinue | Stop-Process -Force
4 changes: 4 additions & 0 deletions .github/workflows/release-desktop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,10 @@ jobs:
overwrite: true
if-no-files-found: error
retention-days: 7
- name: Disconnect from Certum
if: always()
shell: pwsh
run: Get-Process -Name '*SimplySign*' -ErrorAction SilentlyContinue | Stop-Process -Force
- name: Upload signed package size reports
if: steps.reuse.outputs.needs_signing == 'true'
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9
Expand Down
48 changes: 48 additions & 0 deletions docs/CERTUM_SIGNING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,54 @@ needed to authenticate signing, so access to these secrets is signing authority.
Windows 发布使用 Certum SimplySign。配置以上三个 Secret;不要提交二维码或 TOTP
配置。证书私钥保留在云端,但 CI 凭据能授权签名,应按签名权限保护。

## Unattended GitHub Actions signing / GitHub Actions 无人值守签名

The existing release workflow performs login, payload signing, installer signing
and verification on GitHub-hosted Windows runners. No local Windows computer or
per-release phone code is needed once all three credentials are configured.
Keep the `release` environment approval gate: approving a release does not
require manually authenticating each signing operation.

现有发布工作流在 GitHub 托管的 Windows runner 上完成登录、程序签名、安装包签名和
验证。配置齐三个凭据后,不需要本地 Windows 电脑或逐次输入手机验证码。保留
`release` 环境的发布审批;发布审批与签名过程中的人工登录是两回事。

Store the complete original provisioning URI as `CERTUM_OTP_URI` in Actions
secrets, never in a workflow input, repository file or chat. A six-digit phone
code is not a replacement. If the original URI/QR backup is unavailable, the
current automation cannot generate login tokens. Obtain an authorized new
provisioning configuration from Certum before enabling live signing; do not
reset an existing phone enrollment without its owner's approval. Switching to
GitHub Actions cannot recover a missing TOTP secret.

将原始完整配置 URI 保存为 Actions Secret `CERTUM_OTP_URI`,不要放入工作流输入、
仓库文件或聊天。手机六位验证码不能替代它。如果没有原始 URI/二维码备份,当前
自动化无法生成登录验证码,必须先通过 Certum 获取获授权的新配置,才能启用实际
签名。未经所有者批准,不得重置已有手机绑定;改用 GitHub Actions 无法恢复缺失的
TOTP 密钥。

The smoke workflow checks credential format before compiling probes. The shared
login action checks it again, pins the SimplySign installer SHA-256 as well as
its publisher signature, and keeps authentication screenshots disabled. Both
signing workflows disconnect the cloud session even when signing fails. Format
validation does not prove that the account, certificate or TOTP seed is valid;
only a successful live signing test does.

签名测试在编译探针前检查凭据格式;共享登录 Action 再次检查,并同时验证 SimplySign
安装器的固定 SHA-256 和发布者签名,保持登录截图关闭。两个签名工作流在签名失败时
也会断开云签名会话。格式检查不能证明账号、证书或 TOTP 密钥有效,仍须实际签名成功。

Historical Stable versions `0.0.1`–`0.0.6` retain their explicit unsigned policy.
Unlisted versions such as `0.0.7` require Certum automatically and cannot fall
back to unsigned output when credentials or signing fail. Prepare and approve
a new signed candidate rather than silently replacing an existing release.

历史稳定版 `0.0.1`~`0.0.6` 保留明确批准的未签名策略。`0.0.7` 等未列入例外的版本
自动要求 Certum 签名,凭据缺失或签名失败均不得降级为未签名发布。应准备并审批新的
已签名候选,不应直接替换既有发布包。

## Live qualification / 实际签名验收

Run **Certum signing smoke test** on protected `main`, approve the `release`
environment, and require successful login, signing, trust, signer and timestamp
verification. This test publishes nothing. The third-party login action is
Expand Down
43 changes: 43 additions & 0 deletions scripts/validate-certum-configuration.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { pathToFileURL } from "node:url";

// Validate without generating or printing a token. Parser exceptions can include
// the provisioning URI, so only fixed diagnostics may cross this boundary.
export function validateCertumConfiguration(env) {
const errors = [];
if (!env.CERTUM_USERNAME?.trim()) errors.push("CERTUM_USERNAME is missing");
if (!/^[0-9a-fA-F]{40}$/.test(env.CERTUM_KEY_ID ?? "")) {
errors.push("CERTUM_KEY_ID must be the 40-character SHA-1 certificate thumbprint");
}
const value = env.CERTUM_OTP_URI;
if (!value) {
errors.push("CERTUM_OTP_URI is missing; unattended signing needs the original TOTP provisioning URI, not a phone verification code");
} else {
let valid = false;
try {
const uri = new URL(value);
const parameters = uri.searchParams;
const secret = parameters.get("secret") ?? "";
valid = value.startsWith("otpauth://totp/") && !/\s/.test(value)
&& uri.hostname === "totp" && !uri.username && !uri.password && !uri.port && !uri.hash
&& uri.pathname.length > 1 && /^[A-Z2-7]+={0,6}$/i.test(secret)
&& ["secret", "algorithm", "digits", "period"].every(name => parameters.getAll(name).length <= 1)
&& (!parameters.has("algorithm") || ["SHA1", "SHA256", "SHA512"].includes(parameters.get("algorithm").toUpperCase()))
&& (!parameters.has("digits") || /^[678]$/.test(parameters.get("digits")))
&& (!parameters.has("period") || /^[1-9]\d{0,3}$/.test(parameters.get("period")));
} catch {
// Never expose URL parsing errors or provisioning data.
}
if (!valid) errors.push("CERTUM_OTP_URI must be a complete otpauth://totp/ URI with a Base32 secret and supported TOTP parameters");
}
return errors;
}

if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
const errors = validateCertumConfiguration(process.env);
if (errors.length) {
for (const error of errors) console.error(error);
process.exitCode = 1;
} else {
console.log("Certum unattended signing configuration format is valid; live signing must still verify the account and certificate.");
}
}
47 changes: 47 additions & 0 deletions scripts/validate-certum-configuration.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import assert from "node:assert/strict";
import { spawnSync } from "node:child_process";
import test from "node:test";
import { validateCertumConfiguration } from "./validate-certum-configuration.mjs";

const configuration = {
CERTUM_USERNAME: "developer@example.invalid",
CERTUM_KEY_ID: "a".repeat(40),
CERTUM_OTP_URI: "otpauth://totp/SimplySign:developer?secret=JBSWY3DPEHPK3PXP&algorithm=SHA256&digits=6&period=30",
};

test("accepts provisioning parameters used by the pinned login action", () => {
for (const algorithm of ["SHA1", "SHA256", "SHA512", "sha256"]) {
assert.deepEqual(validateCertumConfiguration({ ...configuration,
CERTUM_OTP_URI: configuration.CERTUM_OTP_URI.replace("SHA256", algorithm) }), []);
}
assert.deepEqual(validateCertumConfiguration({ ...configuration,
CERTUM_OTP_URI: "otpauth://totp/SimplySign?secret=JBSWY3DPEHPK3PXP" }), []);
});

test("reports all missing credentials before trying to authenticate", () => {
const errors = validateCertumConfiguration({});
assert.equal(errors.length, 3);
for (const name of Object.keys(configuration)) assert.ok(errors.some(error => error.startsWith(name)));
});

test("rejects phone codes, broken URIs and ambiguous or unsupported TOTP parameters", () => {
for (const uri of ["123456", "otpauth://totp/account", "otpauth://totp/account?secret=123456",
"https://example.invalid/?secret=JBSWY3DPEHPK3PXP", configuration.CERTUM_OTP_URI + "&secret=ABC",
configuration.CERTUM_OTP_URI.replace("SHA256", "MD5"), configuration.CERTUM_OTP_URI.replace("digits=6", "digits=9"),
configuration.CERTUM_OTP_URI.replace("period=30", "period=0"), configuration.CERTUM_OTP_URI + "\n"]) {
assert.equal(validateCertumConfiguration({ ...configuration, CERTUM_OTP_URI: uri }).length, 1);
}
});

test("CLI fails closed and never prints credentials, parser errors or tokens", () => {
for (const uri of [configuration.CERTUM_OTP_URI, "123456", "http://[private-provisioning-data"]) {
const result = spawnSync(process.execPath, [new URL("./validate-certum-configuration.mjs", import.meta.url).pathname], {
encoding: "utf8", env: { ...process.env, ...configuration, CERTUM_OTP_URI: uri },
});
assert.equal(result.status, uri === configuration.CERTUM_OTP_URI ? 0 : 1);
const output = result.stdout + result.stderr;
for (const secret of [configuration.CERTUM_USERNAME, configuration.CERTUM_KEY_ID,
"JBSWY3DPEHPK3PXP", "123456", "private-provisioning-data"]) assert.ok(!output.includes(secret));
assert.doesNotMatch(output, /at new URL|ERR_INVALID_URL/);
}
});
Loading