Electron Mac 开发证书到期

488 阅读2分钟

收到证书到期邮件提醒

  • 证书每年都需要重新申请,有效期一年,初次申请时5.30号,那每年的5.30 号左右到期 。

Developer 您好,

您的 Mac App Distribution 证书将在 30 天后失效。如需生成新的证书,请登录并访问“Certificates, Identifiers & Profiles”(证书、标识符和描述文件)。

证书:Mac App Distribution
团队 ID:YYYYYYYYYY


Developer 您好,

您的 Mac Installer Distribution 证书将在 30 天后失效。如需生成新的证书,请登录并访问“Certificates, Identifiers & Profiles”(证书、标识符和描述文件)。

证书:Mac Installer Distribution
团队 ID:YYYYYYYYYY
  • 到期的证书有两个: Mac App Distribution 和 Mac Installer Distribution 。

处理步骤

1 。重新申请证书 Mac App Distribution 和 Mac Installer Distribution 。

1 首先在 mac 上生成 SCR 文件,

1 打开钥匙串访问。可以通过 Spotlight 搜索“钥匙串访问”来快速找到它。 具体方法
2 在菜单栏中,点击 钥匙串访问 > 证书助理 > 从证书颁发机构请求证书。
- 填写信息,选择“保存到磁盘”。
保存路径是 /Users/yun/Documents/mac_develop/2025/.

2 申请证书 Mac App Distribution 和 Mac Installer Distribution 。

1 申请 Mac App Distribution,需要用到上一步的SCR文件。申请后下载到本地。双击安装。然后到钥匙串访问-证书中设置“始终全部信任”。
2 申请 Mac Installer Distribution,,需要用到上一步的SCR文件。申请后下载到本地。双击安装。然后到钥匙串访问-证书中设置“始终全部信任”。

3 代码中不需要修改任何配置,保留原 appBundleId 和 teamId 、专用 APP 密码 appleIdPassword 不变。

相关代码位置:
1 build/notarization/notarize.js
2 electron/config/builder.json
3 sign.sh

4 需要对代码二进制文件进行重新签名

1 cd /Users/yun/vs2024proj/electron-egg
2 重新编译
./node_modules/.bin/electron-rebuild
3 重新手工处理obotjs 【若不处理这步,代码自动公正一直失败, 手工公正时会提示签名不合法】
-----------

cd ./node_modules/robotjs

rm -rf robotjs-v0.6.0-electron-v109-darwin-arm64.tar.gz

tar -czvf robotjs-v0.6.0-electron-v109-darwin-arm64.tar.gz  build

mv robotjs-v0.6.0-electron-v109-darwin-arm64.tar.gz  /Users/yun/.npm/\_prebuilds/00b3dd-robotjs-v0.6.0-electron-v109-darwin-arm64.tar.gz
--------------


4 对所有二进制文件进行签名
./sign.sh

4 重新打包

npm run ce-build-m-arm64-test

  • 打包后会自动进行公正。
  • 若代码公正失败,则进行手工公正,通过id查询公正失败的原因。