fix(release): base64로 감싼 armored 서명 키도 받는다
pr / ci (pull_request) Successful in 3m37s

진단을 다시 돌리자(signing-check run 11) SIGNING_KEY가 바뀌어 있었다.
4,632글자 한 줄, base64로 읽으면 3,474바이트이고 그 첫 바이트가
`-`였다. 곧 armored 키 파일을 base64로 한 줄에 감싼 값이다(CI secret에
여러 줄 값을 넣을 때 흔히 쓰는 방법). Gradle의 useInMemoryPgpKeys는
armored 글만 읽어서 이 값도 「Could not read PGP secret key」로 실패한다.

build-logic SigningKeys.armoured가 값을 받아, armored 블록을 base64로
감싼 것이면 풀어서 돌려준다. 그 밖의 값은 그대로 돌려줘 원래 오류로
실패하게 한다. 모듈 서명(LibraryPublishingPlugin)과 SBOM 서명(루트
build.gradle)이 이것을 거친다. check-signing-key.sh도 같은 규칙으로 풀어
본다. 「form: base64 of an armoured key file」을 알리고 풀린 글로 나머지를
검사한다. 키는 gpg에 환경 변수 대신 임시 폴더(0700, 끝나면 지움)의 파일로
넘긴다.

버린 대안: 소유자에게 여러 줄로 다시 넣게 하기. 지금 값도 키로는 맞을 수
있고, base64 한 줄은 secret 저장소가 여러 줄을 망가뜨릴 때의 표준 우회다.

검증(desktop, 버리는 RSA 4096 키):
- SigningKeysTest: 클래스가 없어 컴파일 실패(RED) → 통과(GREEN)
- check-signing-key.sh: armored·base64 둘 다 rc=0, base64 + 틀린 암호
  rc=1, 지문 rc=1
- base64 키로 서명 리허설: rc=0, 서명된 artifact 10개, gpg --verify Good
  signature
This commit is contained in:
DongHyeonka
2026-11-08 15:14:28 +09:00
parent 732cb26eb5
commit 97f7381aae
6 changed files with 110 additions and 9 deletions
+19 -5
View File
@@ -24,7 +24,10 @@ if [ -z "${SIGNING_KEY:-}" ]; then
fi
[ -n "${SIGNING_PASSWORD:-}" ] || echo "check-signing-key: SIGNING_PASSWORD is empty (only right for a key without a passphrase)"
EXPECTED_FINGERPRINT=$expected python3 - <<'PY' || fail=1
home=$(mktemp -d)
trap 'rm -rf "$home"' EXIT
chmod 700 "$home"
KEY_OUT=$home/key.asc EXPECTED_FINGERPRINT=$expected python3 - <<'PY' || fail=1
import base64, os, re, sys
key = os.environ["SIGNING_KEY"]
@@ -40,6 +43,18 @@ print(f"shape: {len(key)} characters, {key.count(chr(10)) + 1} lines,"
f" trailing whitespace {'yes' if key[-1:].isspace() else 'no'}")
stripped = key.strip()
compact = re.sub(r"\s", "", key)
if "-----BEGIN" not in key and re.fullmatch(r"[A-Za-z0-9+/]+={0,2}", compact or "x"):
try:
unwrapped = base64.b64decode(compact).decode("utf-8")
except Exception:
unwrapped = ""
if unwrapped.strip().startswith("-----BEGIN PGP PRIVATE KEY BLOCK-----"):
print("form: base64 of an armoured key file on one value; the build unwraps it (SigningKeys), so the checks below read the unwrapped text")
key = unwrapped
stripped = key.strip()
print(f"unwrapped shape: {len(key)} characters, {key.count(chr(10)) + 1} lines")
if re.fullmatch(r"(0x)?[0-9A-Fa-f]{8}|(0x)?[0-9A-Fa-f]{16}|[0-9A-Fa-f]{40}", stripped):
expected = os.environ.get("EXPECTED_FINGERPRINT", "")
same = " (the release key's fingerprint)" if expected and stripped.upper() == expected.upper() else ""
@@ -115,13 +130,12 @@ if raw:
for problem in problems:
print(f"PROBLEM: {problem}")
with open(os.environ["KEY_OUT"], "w", encoding="utf-8") as out:
out.write(key)
sys.exit(1 if problems else 0)
PY
home=$(mktemp -d)
trap 'rm -rf "$home"' EXIT
chmod 700 "$home"
if printf '%s\n' "$SIGNING_KEY" | GNUPGHOME="$home" gpg --batch --quiet --import >/dev/null 2>&1; then
if [ -s "$home/key.asc" ] && GNUPGHOME="$home" gpg --batch --quiet --import "$home/key.asc" >/dev/null 2>&1; then
fingerprint=$(GNUPGHOME="$home" gpg --batch --with-colons --list-secret-keys 2>/dev/null | awk -F: '/^fpr/{print $10; exit}')
echo "gpg import: ok, secret key fingerprint ${fingerprint:-none}"
if [ -n "$expected" ] && [ "${fingerprint:-}" != "$expected" ]; then