From a892a4507377d79cc0f22c3c0ebb2996f836d9fd Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Sun, 8 Nov 2026 15:21:16 +0900 Subject: [PATCH] =?UTF-8?q?fix(release):=20=EC=84=9C=EB=AA=85=20=EC=A7=84?= =?UTF-8?q?=EB=8B=A8=EC=9D=B4=20=EB=B9=84=EB=B0=80=EB=B2=88=ED=98=B8=20?= =?UTF-8?q?=EB=AA=A8=EC=96=91=EC=9D=84=20=EC=95=8C=EB=A6=AC=EA=B3=A0=20Gra?= =?UTF-8?q?dle=20=EC=84=9C=EB=AA=85=EA=B8=B0=EB=A1=9C=EB=8F=84=20=EC=84=9C?= =?UTF-8?q?=EB=AA=85=ED=95=B4=20=EB=B3=B8=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit signing-check(run 13)에서 base64를 푼 키는 맞았다. armor·CRC24·tag 5가 정상이고, 가져온 키 지문이 릴리스 키 92646CEA…F791F8AB였다. 남은 실패는 「SIGNING_PASSWORD로 서명이 안 된다」 하나인데, 비밀번호가 틀렸는지, 붙여 넣을 때 줄바꿈·공백이 섞였는지, gpg 쪽 문제인지 가를 수 없었다. gpg는 비밀번호의 첫 줄만 읽고 Gradle은 값 전체를 쓰므로, gpg 판정이 Gradle 판정과 다를 수도 있었다. - check-signing-key.sh: 비밀번호의 모양(글자 수, 줄바꿈·CR 수, 앞뒤 공백, 비ASCII 수)과 서명 실패 때의 gpg 상태 키워드만 출력한다. 값은 출력하지 않는다. - verifySigningKey: 스크립트 뒤에 Gradle의 in-memory 서명기 (signing.signatory)로 몇 바이트를 서명해 본다. Sign 태스크와 같은 판정이다. 실패 문구는 BouncyCastle 예외 문장뿐이다. 둘 중 하나라도 실패하면 태스크가 실패한다. 검증(로컬 gpg, 버리는 키): 맞는 비밀번호 ok, 틀린 비밀번호 「gpg status: BEGIN_SIGNING FAILURE KEY_CONSIDERED」. 끝에 줄바꿈이 붙은 비밀번호는 gpg로 ok이고 모양 줄이 「line breaks 1」을 알린다(Gradle 판정은 desktop과 runner). --- build.gradle | 24 ++++++++++++++++++++++++ scripts/release/check-signing-key.sh | 21 +++++++++++++++++---- 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index 021e0eb..ef690e8 100644 --- a/build.gradle +++ b/build.gradle @@ -198,12 +198,36 @@ def signingKey = SigningKeys.armoured(providers.environmentVariable('SIGNING_KEY // SIGNING_PASSWORD signs with it, printing no part of either. Gradle's signing reports every one of // these as "Could not read PGP secret key" (v1.0.0 release run 9); this says which. A key other // than the release key passes with -PsigningKeyFingerprint= (a rehearsal key). +// gpg reads only a passphrase's first line and Gradle the whole value, so the task then signs a few +// bytes with Gradle's own signatory: the verdict is the one the Sign tasks would reach. tasks.register('verifySigningKey', Exec) { group = 'verification' description = 'Checks SIGNING_KEY and SIGNING_PASSWORD without printing them (scripts/release/check-signing-key.sh).' outputs.upToDateWhen { false } + ignoreExitValue = true commandLine 'bash', file('scripts/release/check-signing-key.sh'), providers.gradleProperty('signingKeyFingerprint').getOrElse('') + def signed = !signingKey.isBlank() + doLast { + boolean scriptPassed = executionResult.get().exitValue == 0 + boolean gradlePassed = !signed + String verdict = 'skipped: no SIGNING_KEY' + if (signed) { + try { + signing.signatory.sign(new ByteArrayInputStream('signing check'.bytes), OutputStream.nullOutputStream()) + gradlePassed = true + verdict = 'ok' + } catch (Exception failure) { + // Exception text only: BouncyCastle names what failed (checksum mismatch, a tag), never the key. + def cause = failure.cause ? " (${failure.cause.class.simpleName}: ${failure.cause.message})" : '' + verdict = "failed: ${failure.message}${cause}" + } + } + logger.lifecycle("signing as Gradle's Sign tasks do (in-memory key): ${verdict}") + if (!scriptPassed || !gradlePassed) { + throw new GradleException('verifySigningKey: the signing secrets would not sign; the PROBLEM lines above say why.') + } + } } tasks.withType(Sign).configureEach { mustRunAfter tasks.named('verifySigningKey') diff --git a/scripts/release/check-signing-key.sh b/scripts/release/check-signing-key.sh index d1cb1c6..ea66519 100755 --- a/scripts/release/check-signing-key.sh +++ b/scripts/release/check-signing-key.sh @@ -23,6 +23,15 @@ if [ -z "${SIGNING_KEY:-}" ]; then exit 1 fi [ -n "${SIGNING_PASSWORD:-}" ] || echo "check-signing-key: SIGNING_PASSWORD is empty (only right for a key without a passphrase)" +# The passphrase's shape only: a pasted value often carries a line break or spaces the key was not +# protected with, and Gradle uses the value as given. +python3 - <<'PY' +import os +p = os.environ.get("SIGNING_PASSWORD", "") +print(f"password shape: {len(p)} characters, line breaks {p.count(chr(10))}, CR {p.count(chr(13))}," + f" leading whitespace {'yes' if p[:1].isspace() else 'no'}, trailing whitespace {'yes' if p[-1:].isspace() else 'no'}," + f" non-ASCII characters {sum(1 for c in p if ord(c) > 127)}") +PY home=$(mktemp -d) trap 'rm -rf "$home"' EXIT @@ -143,12 +152,16 @@ if [ -s "$home/key.asc" ] && GNUPGHOME="$home" gpg --batch --quiet --import "$ho fail=1 fi printf 'signing check\n' > "$home/message" - if printf '%s' "${SIGNING_PASSWORD:-}" | GNUPGHOME="$home" gpg --batch --pinentry-mode loopback \ - --passphrase-fd 0 --local-user "${fingerprint:-none}" --detach-sign --output "$home/message.sig" \ - "$home/message" >/dev/null 2>&1; then + # gpg reads only the first line of the file; the shape line above says whether there is more. + printf '%s' "${SIGNING_PASSWORD:-}" > "$home/passphrase" + if GNUPGHOME="$home" gpg --batch --pinentry-mode loopback --passphrase-file "$home/passphrase" \ + --status-fd 3 --local-user "${fingerprint:-none}" --detach-sign --output "$home/message.sig" \ + "$home/message" >/dev/null 2>&1 3>"$home/status"; then echo "signing with SIGNING_PASSWORD: ok" else - echo "PROBLEM: SIGNING_PASSWORD does not unlock the key for signing (wrong passphrase, or the key is not a signing key)" + # gpg's status keywords only (BAD_PASSPHRASE, MISSING_PASSPHRASE, ERROR …): no values. + status=$(awk '$1 == "[GNUPG:]" {print $2}' "$home/status" | sort -u | tr '\n' ' ') + echo "PROBLEM: SIGNING_PASSWORD does not unlock the key for signing (gpg status: ${status:-none})" fail=1 fi else