0

我正在 Visual Studio for Mac下使用.NET Framework 4.5.2开发应用程序

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

为了尝试纠正这个问题,我添加--options了 LoginApp 的参数。

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 ([...])"参数。

4

0 回答 0