【发布时间】:2022-06-22 14:25:43
【问题描述】:
我正在使用 .NET Framework 4.5.2 在Visual Studio for Mac下开发一个应用程序。
Apple 已为其最新的 Mac 版本添加了安全功能,因此我想对应用程序进行公证,以便 Gatekeeper 可以读取生成的票证,并且下载该应用程序的其他 Mac 用户在启动该应用程序时不会收到安全警告.
借助 Xamarin.Mac 在 Visual Studio 构建应用程序后,我手动运行了一些命令以对 .app 进行签名。然后,我创建一个安装程序,生成一个包含 .app 文件的 .dmg 文件。然后,我将 .dmg 文件发送到公证服务,它会生成包含以下两行的报告。
"status": "Invalid",
"statusSummary": "Archive contains critical validation errors",
对 .app 进行签名的命令如下。
codesign -vvv --strict --force --timestamp --options runtime MyApp.app/Contents/Frameworks/MyFramework.framework/Versions/A/Resources/UpdateApp.app/Contents/MacOS/UpdateApp
codesign -vvv --strict --force --timestamp MyApp.app/Contents/Frameworks/MyFramework.framework/Versions/A/MyFramework
codesign -vvv --strict --force --timestamp MyApp.app/Contents/Library/loginItems/LoginApp.app
codesign -vvv --strict --force --timestamp --options runtime MyApp.app/Contents/PlugIns/FinderExt.appex
codesign -vvv --strict --force --timestamp MyApp.app
双击 .app 文件启动应用程序,这正是我想要的。但是公证报告说
The executable does not have the hardened runtime enabled.
适用于以下两个应用程序
MyApp.dmg/MyApp.app/Contents/Library/loginItems/LoginApp.app/Contents/MacOS/LoginApp
MyApp.dmg/MyApp.app/Contents/MacOS/MyApp
为了尝试纠正这个问题,我为 LoginApp 添加了--options 参数。
codesign -vvv --strict --force --timestamp --options runtime MyApp.app/Contents/Frameworks/MyFramework.framework/Versions/A/Resources/UpdateApp.app/Contents/MacOS/UpdateApp
codesign -vvv --strict --force --timestamp MyApp.app/Contents/Frameworks/MyFramework.framework/Versions/A/MyFramework
codesign -vvv --strict --force --timestamp --options runtime MyApp.app/Contents/Library/loginItems/LoginApp.app
codesign -vvv --strict --force --timestamp --options runtime MyApp.app/Contents/PlugIns/FinderExt.appex
codesign -vvv --strict --force --timestamp MyApp.app
双击 .app 文件仍会启动应用程序,这正是我想要的。而且公证报告还是写着
The executable does not have the hardened runtime enabled.
但仅适用于第二个应用程序,即未修改 codesign 命令的应用程序。
MyApp.dmg/MyApp.app/Contents/MacOS/MyApp
因此,在我看来,要成功公证应用程序,我所要做的就是以同样的方式修改第二个 codesign 命令。
codesign -vvv --strict --force --timestamp --options runtime MyApp.app/Contents/Frameworks/MyFramework.framework/Versions/A/Resources/UpdateApp.app/Contents/MacOS/UpdateApp
codesign -vvv --strict --force --timestamp MyApp.app/Contents/Frameworks/MyFramework.framework/Versions/A/MyFramework
codesign -vvv --strict --force --timestamp --options runtime MyApp.app/Contents/Library/loginItems/LoginApp.app
codesign -vvv --strict --force --timestamp --options runtime MyApp.app/Contents/PlugIns/FinderExt.appex
codesign -vvv --strict --force --timestamp --options runtime MyApp.app
我是对的,因为公证报告不再显示错误,并且为 Gatekeeper 生成了一张票。但是,当我双击 .app 以运行该应用程序时,这一次它并没有启动。在 Mac 的控制台应用程序中,我可以看到生成的崩溃报告包含以下几行。
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
我不明白我怎么会遇到SIGSEGV 崩溃,因为应用程序完全相同,并且只有 codesign 命令经过调整以便应用程序得到公证。
我可以启动应用程序或对其进行公证,而我想要两者兼有,一个经过公证的应用程序也可以在不崩溃的情况下启动,就像在codesign 之前一样命令。
我已经阅读了以下两页关于该主题的 Apple 文档,并且我认为我已经遵循了所有给定的建议,但未能解决我的问题。
https://developer.apple.com/documentation/security/notarizing_macos_software_before_distribution
https://developer.apple.com/documentation/security/notarizing_macos_software_before_distribution/resolving_common_notarization_issues
我已经尝试了一段时间,并尝试了codesign 命令和参数的几种组合。我错过了什么?提前感谢任何指针。
注意: 所有codesign 命令还包含一个--sign "Developer ID Application: MyCompany ([...])" 参数。
【问题讨论】:
标签: c# exc-bad-access packaging visual-studio-mac notarization