Skip to content

Commit 88eadfb

Browse files
fix(build): preserve binary identifier when signing via temp-path copy (#1255)
* fix(build): preserve binary identifier when signing via temp-path copy The temp-path codesign workaround for non-standard Python.framework bundles signed each binary without --identifier, so codesign derived the identifier from the random temp filename (e.g. 'tmp.XXXXXX'). Apple's notarization service then rejected those binaries with 'The signature of the binary is invalid' -- the certificate chain and code hashes are valid, but the identifier doesn't match what the binary originally carried. Fix: extract the existing identifier from the binary (set by PyInstaller's codesign_identity step, typically 'org.python.python') before copying to the temp path, then pass --identifier to the codesign invocation. Falls back to basename if the binary is unsigned. * fix(build): address P2 review findings — use sed for identifier extraction, clean up temp on cp failure
1 parent 0bfc97f commit 88eadfb

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

scripts/package/build_app_tauri.sh

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,28 @@ if [ -n "$APPLE_PERSONALID" ]; then
163163
signed_count=0
164164
while IFS= read -r fw_bin; do
165165
echo " Signing framework binary via temp copy: $fw_bin"
166+
# Preserve the binary's existing code-signing identifier.
167+
# Without --identifier, codesign uses the random temp filename
168+
# (e.g. "tmp.XXXXXX") as the identifier, which makes Apple's
169+
# notarization service report "The signature of the binary is
170+
# invalid" — even though the certificate chain and code hashes
171+
# are valid. Using the original identifier (e.g. "org.python.python"
172+
# from PyInstaller's codesign_identity step) or falling back to the
173+
# binary's filename avoids this rejection.
174+
existing_id=$(codesign -d "$fw_bin" 2>&1 \
175+
| sed -n 's/^Identifier=//p' || true)
176+
if [ -z "$existing_id" ]; then
177+
existing_id=$(basename "$fw_bin")
178+
fi
179+
echo " Using identifier: $existing_id"
166180
tmp_binary=$(mktemp)
167181
cp "$fw_bin" "$tmp_binary"
168-
sign_binary "$tmp_binary" || { rm -f "$tmp_binary"; exit 1; }
169-
cp "$tmp_binary" "$fw_bin"
182+
codesign --force --options runtime --timestamp \
183+
--entitlements "$ENTITLEMENTS" \
184+
--identifier "$existing_id" \
185+
--sign "$APPLE_PERSONALID" \
186+
"$tmp_binary" || { rm -f "$tmp_binary"; exit 1; }
187+
cp "$tmp_binary" "$fw_bin" || { rm -f "$tmp_binary"; exit 1; }
170188
rm -f "$tmp_binary"
171189
signed_count=$((signed_count + 1))
172190
done < <(find "$fw" -type f | xargs file | grep "Mach-O" | cut -d: -f1)

0 commit comments

Comments
 (0)