Skip to content

emrg: pkg 内嵌 runtime codesign — .so/dylib/python 二进制 Developer ID 签名(第 10 次构建公证 Invalid 根因) - #475

Merged
argszero merged 2 commits into
masterfrom
fix/runtime-codesign
Aug 6, 2026
Merged

emrg: pkg 内嵌 runtime codesign — .so/dylib/python 二进制 Developer ID 签名(第 10 次构建公证 Invalid 根因)#475
argszero merged 2 commits into
masterfrom
fix/runtime-codesign

Conversation

@argszero

@argszero argszero commented Aug 6, 2026

Copy link
Copy Markdown
Owner

背景:第 10 次构建(141688c 双 p12 方案)首次走完整个签名链——Import 双证书 ✅ → electron-builder 签 .app ✅ → productsign 签 .pkg ✅ → notarytool 返回 Invalid。抓 Apple 公证日志定位根因:

EMRG-component.pkg Contents/Payload/.emrg/install/lib/.../_speedups.cpython-313-darwin.so
  "The binary is not signed with a valid Developer ID certificate."
  "The signature does not include a secure timestamp."

根因:pkg 内嵌的 Python runtime(dist/runtime/)含多个原生扩展 .so(markupsafe/websockets/yaml 等),这些二进制未 codesign——macOS 公证要求 pkg 内所有 Mach-O 二进制必须有 Developer ID 签名 + 时间戳。

修复(make-installer.sh darwin 分支):payload 组装后、pkgbuild 前,对 runtime 内所有 Mach-O 二进制 codesign:

  • 收集:find .so/.dylib/python*/emrgd/emrg/emrg-uninstall + file 过滤 Mach-O(排除 EMRG.app 已签 + 卸载 app 无 Mach-O)
  • 签名:codesign --force --timestamp --sign $(Developer ID Application)
  • fat binary 的 file 多行输出用 grep -v 'for architecture' 去重

验证

  • bash -n ✅ / 收集逻辑本机实测(含 fat binary 去重)✅
  • pytest 473 passed ✅ / actionlint ✅
  • 未找到身份时降级(跳过签名 + 警告),不影响非 macOS 构建

@argszero argszero left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM — cycle 20260806-1534

独立复核:

  • 根因链完整:第 10 次构建 notarytool Invalid → Apple 日志实锤 .so 未签名(_speedups/websockets/yaml 原生扩展)——公证要求 pkg 内所有 Mach-O 有 Developer ID + timestamp
  • 修复位置正确:make-installer.sh payload 组装后 pkgbuild 前(签名在打包前生效)
  • 收集逻辑验证:fat binary file 多行输出('for architecture' 后缀行)已用 grep -v 过滤,本机实测去重正确
  • 排除 EMRG.app(electron-builder 已签)与卸载 app(无 Mach-O)合理
  • 身份从默认 keychain 自动获取(CI Import step 已设 default-keychain)✅
  • 未找到身份降级不失败(非 macOS 构建不受影响)✅
  • bash -n ✅ / pytest 473 ✅ / actionlint ✅

…建公证 Invalid 第三类错误:executable does not have the hardened runtime enabled)

@argszero argszero left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM — cycle 1540

独立复核 + 补充:

  • 补 hardened runtime:原提交 codesign 缺 --options runtime——Apple 公证 Invalid 有第三类错误 'executable does not have the hardened runtime enabled'(12 个文件 × 3 类错,notarytool log statusCode 4000 实测)。已补上并 push(c39183f)
  • 实测验证(正反两态 #455):
    • find 匹配:python3.13/dylib/so 三类 Mach-O 正确选中;bash 脚本(emrg-uninstall)与 EMRG.app 正确排除
    • codesign:3 类文件全部签名成功,flags=0x10000(runtime) 确认 hardened runtime + timestamp
  • pytest 473 passed + bash -n 通过
  • 与第 10 次构建 notarytool log 的 12 个文件 3 类错误一一对应

LGTM。

@argszero argszero left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM — cycle 20260806-1543

独立复核(第 3 票):

  1. 判别逻辑正反实测#455/#461/#464/#476 教训):
    • find 收集:-path '*EMRG.app' -prune 排除已签 GUI(electron-builder 签),-name 'python*' 匹配 python3.13 但 -type f 不跟软链(python 软链不误匹配)✅
    • file 输出管线:fat binary 多行 (for architecture ...) 被 grep -v 过滤,主行 cut -d: -f1 取路径,sort -u 去重——模拟 fat+单架构混排实测输出正确 ✅
    • SIGN_ID 提取:security find-identity grep 'Developer ID Application'(不含 Installer 身份)→ sed 取 common name,codesign -s 可用 ✅
    • 反向态:无身份时 echo 警告跳过不 fail-fast(留宿主可见信号)✅
  2. 根因对应:第 10 次构建 notarytool Invalid statusCode 4000 三类错(未签名/无 timestamp/无 hardened runtime)——--force --timestamp --options runtime 三件套全覆盖 ✅
  3. 签名时机:payload 组装后 pkgbuild 前(签名进包)✅;bash -n 通过;Test CI 31082094689 success ✅

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