macOS开发应用Sign(签名)和Notarizaiton(公证)
签名
可执行文件签名:
codesign -f -s ${证书ID} --timestamp ${签名文件}
.Pkg安装文件签名:
productsign --timestamp --sign ${证书ID} ${.pkg签名文件} ${.pkg签名后文件}
公证
新闻:苹果强制启用公证
2020年2月3日起,Mac App Store 以外通过其他途径分发的 Mac 软件必须经过 Apple 公证,才能在 macOS Catalina 中运行
公证命令
xcrun altool --notarize-app --primary-bundle-id ${AppBundleID 唯一标识} --username ${AppleID} --asc-provider ${证书提供者} --password ${应用公证专用密码} --file ${公证文件}
asc-provider
:证书提供者,查询命令如下:
xcrun altool --list-providers -u ${AppleID} -p ${应用公证专用密码}
问题1: The executable does not have the hardened runtime enabled
在公证后的报告中,遇到"message": "The executable does not have the hardened runtime enabled."
错误是因为编译的时候没有开启hardened runtime
导致的,可以采用codesign --options runtime --entitlements ${path}/app.entitlements
解决,其中app.entitlements
内容如下:
<?xml version="1.0" encoding="UTF-8"?>
com.apple.security.cs.disable-library-validation
com.apple.security.automation.apple-events
com.apple.security.cs.allow-unsigned-executable-memory
com.apple.security.cs.allow-jit
com.apple.security.cs.allow-dyld-environment-variables
com.apple.security.cs.disable-executable-page-protection
参考文章
[1] Mac notarizing 公证使用记录
[2] Mac app 打包时 Notarizition(公证)相关需求记录
[3] Mac开发-公证流程记录Notarizaiton-附带脚本
[4]