Mac notarizing 公证使用记录

1. 关于公证苹果官方文档

官方公证文档

2. 新闻:苹果强制启用公证

2020年2月3日起,Mac App Store 以外通过其他途径分发的 Mac 软件必须经过 Apple 公证,才能在 macOS Catalina 中运行

3. 公证流程

  1. 苹果官方,申请账号、密码、证书

  2. dmgpkgzip包,进行签名

  3. 提交dmgpkgzip包,到Apple服务器

$ xcrun altool --notarize-app --primary-bundle-id "软件ID" --username "苹果账号" --password "密码" --file "本地文件路径"

提交后,会返回一个RequestUUID, 用这个id,获取公证结果。

公证有3中状态:success invalid in Progress

$ xcrun altool --notarization-info "服务器返回的RequestUUID" -u "苹果账号" -p "密码"

备注:公证结果, 也会发送至您注册苹果账号时邮箱中。

  1. 获取公证历史记录
$ xcrun altool --notarization-history 0 -u "苹果账号" -p "密码" | head -n 20

4. 公证可能遇到的问题

问题1: The executable does not have the hardened runtime enabled.

解决方法:对软件签名时候,增加选项 --options=runtime

$ codesign --options=runtime -f -s "证书名称" "文件"
问题2: The signature does not include a secure timestamp.

解决方法:对软件签名时候,增加选项 --timestamp

$ codesign --timestamp 
问题3: The binary is not signed.

有的时候发现对dmg包或zip包,都整体签名了。为什么还会提示这个?

因为:公证的软件包内,所有的可执行文件,都需要签名。

5. hardened.entitlements

entitlements官方文档

注意:增加的时候,千万不要出现重复值。大坑。

示例:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>com.apple.security.cs.allow-unsigned-executable-memory</key>
    <true/>
    <key>com.apple.security.cs.allow-jit</key>
    <true/>
    <key>com.apple.security.device.audio-input</key>
    <true/>
    <key>com.apple.security.device.bluetooth</key>
    <true/>
    <key>com.apple.security.device.camera</key>
    <true/>
    <key>com.apple.security.device.print</key>
    <true/>
    <key>com.apple.security.device.usb</key>
    <true/>
    <key>com.apple.security.cs.disable-executable-page-protection</key>
    <true/>
    <key>com.apple.security.cs.disable-library-validation</key>
    <true/>
    <key>com.apple.security.cs.allow-dyld-environment-variables</key>
    <true/>
</dict>
</plist>

6. codesign 命令详解

查看codesign命令帮助

$ man codesign

签名

$ codesign --entitlements=hardened.entitlements --timestamp --options=runtime -f -s  "证书名称" "文件" 

查看签名

$ codesign -dvvv filename.dmg

移除签名

$ codesign --remove-signature filename.dmg
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容