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).
This commit is contained in:
@@ -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=<its fingerprint> (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')
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user