Skip to content

Commit aacd0c8

Browse files
Mikarina13claude
andcommitted
fix(sign): fail clearly on ambiguous Developer ID (duplicate-CN keychains)
When the keychain holds >1 codesigning identity with the same Common Name (common after a cert re-issue — leaves an orphan), codesign aborts with a cryptic "ambiguous … matches A and B" and the release pipeline dies at the sign step. sign_app.sh now pre-detects this: if --identity is a CN (not a 40-hex SHA-1) matching multiple identities, it prints the conflicting certs + their SHA-1s and tells the operator to re-run with the specific SHA-1. Turns a cryptic failure into actionable guidance. (Hex-SHA-1 identities skip the check.) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent df5850d commit aacd0c8

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

packaging/macos/sign_app.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,23 @@ if [ "$DRY_RUN" -eq 0 ] && [ -z "$IDENTITY" ]; then
5353
exit 1
5454
fi
5555

56+
# Ambiguity guard: codesign fails cryptically ("ambiguous … matches A and B") when
57+
# the keychain has >1 identity with the same Common Name. If --identity was given
58+
# as a CN (not a 40-hex SHA-1) and matches multiple identities, fail clearly and
59+
# tell the operator to pass the specific SHA-1 instead.
60+
if [ "$DRY_RUN" -eq 0 ] && ! printf '%s' "$IDENTITY" | grep -Eq '^[0-9A-Fa-f]{40}$'; then
61+
_matches="$(security find-identity -v -p codesigning 2>/dev/null \
62+
| grep -F "$IDENTITY" || true)"
63+
_n="$(printf '%s\n' "$_matches" | grep -c . || true)"
64+
if [ "${_n:-0}" -gt 1 ]; then
65+
echo "sign_app.sh: signing identity '$IDENTITY' is AMBIGUOUS — $_n certs share that name:" >&2
66+
printf '%s\n' "$_matches" | sed 's/^/ /' >&2
67+
echo " Re-run with the specific SHA-1, e.g.:" >&2
68+
echo " --identity $(printf '%s\n' "$_matches" | head -1 | awk '{print $2}')" >&2
69+
exit 1
70+
fi
71+
fi
72+
5673
codesign_one() {
5774
local target="$1"
5875
if [ "$DRY_RUN" -eq 1 ]; then

0 commit comments

Comments
 (0)