NW.js Mac App 签名公证流程

使用 Developer ID 为 Mac 软件签名 - Apple Developer

在MacOS 10.15之前,应用如果没有签名(signature),那么首次打开时就会弹出“无法验证开发者”的安全提示,因此只要签名了,就可以正常打开软件,
从 10.15 版本后,从 App Store 之外分发的 App 都需要经过 Apple 公证(notarize),否则会弹出“无法打开”,“移到废纸篓”的提示,,非常影响用户第一印象和使用,这就需要再签名之后,再进行公证。下面简单记录一下 mac 下 App 签名和公证的流程。

签名

生成证书请求文件

  1. 进入钥匙串,在菜单中选择 “Certificates” - “Request a Certificate From A Certificate Authority”

  1. 在弹窗中填写如下信息。

填写完后保存到本地,文件名为CertificateSigningRequest.certSigningRequest

在开发者中心创建证书

登录 Apple Developer,进入 Certificates, IDs & Profiles 页面,点击添加按钮,选择 Mac App Distribution

上传刚才添加的 CertificateSigningRequest.certSigningRequest 文件

上传成功后点击下载,将证书保存到本地。

安装证书

  1. 双击下载到本地的证书,添加到钥匙串,如下:

  1. 右键双击,导出证书为 .cer 格式

  1. 打开命令行工具,添加证书

sudo security add-trusted-cert -d -r trustRoot -p codeSign -k /Library/Keychains/System.keychain ~/Desktop/Certificates.cer

Security是Mac系统中钥匙串和安全模块的命令行管理工具,了解更多Security命令,参考:
Mac Security工具使用总结

  1. 添加成功后通过命令查看已添加的证书

security find-identity -p codesigning

如果添加错误,需要删除证书,则使用如下命令:

sudo security delete-certificate -Z 36A8CEEBCA9CC8FA3CAC9B7EA165AA062DCxxxxxx

  1. 进行签名

codesign -f -s "3rd Party Mac Developer Application: xxxx xxx Co. Ltd. (6755xxxxx)" -v "/Users/wangxi/Desktop/Codes/weixin-work/dist/xxxx.app" --deep

6.查看是否签名成功

codesign -vv /Users/wangxi/Desktop/Codes/weixin-work/dist/xxx.app


公证

对您的 Mac 软件进行公证以在 macOS Catalina 中运行 - 新闻 - Apple Developer

公证流程主要通过一行命令,如下:

  1. 获取命令相关字段值
  • primary-bundle-id :当前需要公证 App 的 ID,在苹果开发者后台 Profiles 详情中可以查看(如果没有的话,需要手动添加)

  • username:苹果开发者ID

  • password:应用专用密码。(登录 appleid.apple.com ,点击 Generate Password,创建一个应用专用密码,这样可以避免暴露真实的密码。

  • asc-provider:证书提供者(ProviderShortname)。查询命令如下:

xcrun altool —list-providers -u "apple id" -p "app password"

  • file:需要公证的 App 路径,支持 dmg,zip 和 pkg

填写完对应字段完整的命令如下:

xcrun altool --notarize-app --primary-bundle-id "com.xxx.www" --username "xxx@xxx.com" --password "jvqz-jyym-xxx-xxxxx" --asc-provider "67559xxxxxx" --file "/Users/wangxi/Desktop/Codes/weixin-work/dist/xxx.app.zip"

  1. 执行命令,请求成功后会返回一串字符 RequestUUID

  1. 查询公证结果(一般两分钟左右就会出公证结果)

xcrun altool —notarization-info 78830f47-ecb9-42a6-b9a1-f82922exxxxx —username "xxx@xxx.com" —password "seqb-msgu-eata-xxxx"

如果公证通过,一会儿就会收到 Apple 发送的邮件

如果未通过,可以通过返回的 LogFileURL 查看错误日志,修复相关问题后重新执行公证流程。

参考

MAS: Requesting certificates · nwjs/nw.js Wiki · GitHub

nwjs mac app签名 - 小咔蹭的个人页面 - OSCHINA

iOS包重签名技术知识 - 简书

macOS 下 Electron 程序的签名及公证

codesign gives always no identity found error via terminal

Mac Electron 应用的签名(signature)和公证(notarization) - 海角在眼前 - 博客园

Mac开发-公证流程记录Notarizaiton-附带脚本_CaicaiNo.1-CSDN博客_mac公证

Mac Security工具使用总结 - XRacoon - 博客园

Apple Developer Documentation

Mac notarizing 公证使用记录 - 简书

Apple Developer Documentation

posted @ 2020-07-10 10:02  Raychan  阅读(2773)  评论(0编辑  收藏  举报