Skip to content

Fix notarization 401 by trimming the ASC key-id and issuer - #7

Merged
chandlerhuff merged 1 commit into
mainfrom
fix/notarize-credentials-trim
Jul 14, 2026
Merged

chandlerhuff merged 1 commit into
mainfrom
fix/notarize-credentials-trim

Conversation

@chandlerhuff

Copy link
Copy Markdown
Member

Problem

After #6 fixed the PEM parsing, notarization fails one step later:

xcrun notarytool submit ... --key-id '***' --issuer '***' --wait
Error: HTTP status code: 401. Unauthenticated.

This is progress — notarytool parsed the key, built a signed JWT, and reached Apple. Apple returned 401 (credentials rejected), not 403 (authorized-but-forbidden), which points at the JWT claims: the --key-id (kid) or --issuer (iss).

Those were interpolated into the command verbatim:

"--key-id '#{ENV['CONNECT_API_KEY_ID']}' " \
"--issuer '#{ENV['CONNECT_API_ISSUER_ID']}' " \

The .p8 in the same Vault store arrived with mangled newlines (that was #6). The key-id / issuer secrets almost certainly carry the same trailing newline, which becomes part of kid/iss → Apple can't match the key → 401.

Fix

  • .strip the key-id and issuer in both notarize_binaries and connect_api_key.
  • Fail early with a clear message if either still contains internal whitespace after trimming.

If it still 401s, the values themselves are wrong

Trimming only fixes stray whitespace. If auth still fails, verify the triple directly with a lightweight probe that authenticates and lists history without uploading anything:

xcrun notarytool history --key AuthKey.p8 --key-id "$CONNECT_API_KEY_ID" --issuer "$CONNECT_API_ISSUER_ID"
  • key-id — the 10-char ID from the key's row under App Store Connect → Users and Access → Integrations → App Store Connect API (also embedded in the AuthKey_<KEYID>.p8 filename).
  • issuer — the 36-char UUID at the top of that same page.
  • the key must belong to the same team as the Developer ID certificate.

🤖 Generated with Claude Code

With the .p8 now parsed correctly, notarytool reaches Apple and fails
with "401 Unauthenticated". The key-id and issuer were interpolated into
the notarytool command straight from the environment, so a trailing
newline on those Vault secrets -- the same mangling that corrupted the
key -- lands inside the JWT kid/iss claims and Apple rejects the request.

Strip both values before use in notarize_binaries and connect_api_key,
and fail early with a clear message if either still contains internal
whitespace after trimming.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@chandlerhuff
chandlerhuff merged commit 6c4e3f4 into main Jul 14, 2026
2 checks passed
@chandlerhuff
chandlerhuff deleted the fix/notarize-credentials-trim branch July 14, 2026 13:58
@chandlerhuff chandlerhuff self-assigned this Jul 14, 2026
chandlerhuff added a commit that referenced this pull request Jul 14, 2026
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant