#c# #macos #sqlite #code-signing #xamarin.mac
#c# #macos #sqlite #подписание кода #xamarin.mac
Вопрос:
Я разрабатываю приложение C # в Visual Studio для Mac.
Я настроил его на подпись с идентификатором разработчика, чтобы он был нотариально заверен Apple.
Но это не работает.
Вот шаги.
(1). Подпишите код с помощью Visual Studio для Mac.
(2). Однако этот файл .app приведет к сбою.
(3). Когда я создаю dmg и запрашиваю нотариальное заверение с помощью команды xcrun altool, я получаю следующую ошибку.
{
"logFormatVersion": 1,
"jobId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"status": "Invalid",
"statusSummary": "Archive contains critical validation errors",
"statusCode": 4000,
"archiveFilename": "MyApp.dmg",
"uploadDate": "2020-08-18T08:29:55Z",
"sha256": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"ticketContents": null,
"issues": [
{
"severity": "error",
"code": null,
"path": "MyApp.dmg/MyApp.app/Contents/MonoBundle/SQLite.Interop.dll",
"message": "The signature of the binary is invalid.",
"docUrl": null,
"architecture": "x86_64"
}
]
}
Даже если это удастся, это не будет иметь значения, потому что произойдет сбой…
Думая, что SQLite.Interop.dll причиной было то, что я подписал код непосредственно после шага (1), и он успешно запустился.
$ codesign --force --verify --verbose
--sign "Developer ID Application: MyCompany (XXXXXXXXX)"
"SQLite.Interop.dll"
--deep
--options runtime
--timestamp
Однако запрос нотариального заверения с помощью команды xcrun altool возвращает ошибку, подобную этой:
{
"logFormatVersion": 1,
"jobId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"status": "Invalid",
"statusSummary": "Archive contains critical validation errors",
"statusCode": 4000,
"archiveFilename": "MyApp.dmg",
"uploadDate": "2020-08-18T08:29:55Z",
"sha256": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"ticketContents": null,
"issues": [
{
"severity": "error",
"code": null,
"path": "MyApp.dmg/MyApp.app/Contents/MacOS/MyApp",
"message": "The signature of the binary is invalid.",
"docUrl": null,
"architecture": "x86_64"
}
]
}
Я думаю, это связано с изменением подписи зависимостей SQLite.Interop.dll , что привело к неправильной подписи в MyApp.
Как я могу это решить?
Вот что я уже пробовал.
- Снова подпишите MyApp.dmg/MyApp.app/Contents / macOS/ MyApp вручную.
- Подпишите SQLite.Interop.dll вручную перед процедурой (1).
Вот некоторая информация, которая поможет
- Настройки для подписи файлов .csproj
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Optimize>true</Optimize>
<OutputPath>binRelease</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<EnableCodeSigning>true</EnableCodeSigning>
<CreatePackage>false</CreatePackage>
<EnablePackageSigning>false</EnablePackageSigning>
<IncludeMonoRuntime>true</IncludeMonoRuntime>
<UseSGen>true</UseSGen>
<UseRefCounting>true</UseRefCounting>
<LinkMode>SdkOnly</LinkMode>
<AOTMode>None</AOTMode>
<CodeSigningKey>Developer ID Application: MyCompany (XXXXXXXXXXX)</CodeSigningKey>
<PackageSigningKey>3rd Party Mac Developer Installer</PackageSigningKey>
<UseHardenedRuntime>true</UseHardenedRuntime>
<CodeSignEntitlements>Entitlements.plist</CodeSignEntitlements>
<CodeSignExtraArgs>--deep</CodeSignExtraArgs>
</PropertyGroup>
- Entitlements.plist
<?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-jit</key>
<true/>
</dict>
</plist>
Я использую SQLite.Interop.dll в System.Data.SQLite.Ядро, которое я получил от NuGet.
packages/System.Data.SQLite.Core.1.0.111.0/runtimes/osx-x64/native/netstandard2.0/SQLite.Interop.dll
postscript 2020/08/31 15:52:
Часть журнала сборки Visual Studio для Mac:
Target GenerateSatelliteAssemblies:
Creating directory "obj/Release/en".
/Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/4.5/al.exe /culture:en /out:obj/Release/en/MyApp.resources.dll /template:obj/Release/MyApp.exe /embed:obj/Release/improvementproductivityforMac.Resources.AppResources.en.resources
Target _CopyFilesMarkedCopyLocal:
Copying file from "/Users/tomityu/Gits/my-app/packages/NLog.4.6.6/lib/netstandard2.0/NLog.dll" to "/Users/tomityu/Gits/my-app/MyApp/bin/Release/NLog.dll".
Copying file from "/Users/tomityu/Gits/my-app/packages/System.Data.SQLite.Core.1.0.111.0/lib/netstandard2.0/System.Data.SQLite.xml" to "/Users/tomityu/Gits/my-app/MyApp/bin/Release/System.Data.SQLite.xml".
Copying file from "/Users/tomityu/Gits/my-app/packages/NLog.4.6.6/lib/netstandard2.0/NLog.xml" to "/Users/tomityu/Gits/my-app/MyApp/bin/Release/NLog.xml".
Copying file from "/Users/tomityu/Gits/my-app/packages/System.Data.SQLite.Core.1.0.111.0/lib/netstandard2.0/System.Data.SQLite.dll" to "/Users/tomityu/Gits/my-app/MyApp/bin/Release/System.Data.SQLite.dll".
Copying file from "/Users/tomityu/Gits/my-app/packages/System.Data.SQLite.Core.1.0.111.0/lib/netstandard2.0/System.Data.SQLite.dll.config" to "/Users/tomityu/Gits/my-app/MyApp/bin/Release/System.Data.SQLite.dll.config".
Creating "/Users/tomityu/Gits/my-app/MyApp/obj/Release/MyApp.csproj.CopyComplete" because "AlwaysCreate" was specified.
Target CopyFilesToOutputDirectory:
Copying file from "/Users/tomityu/Gits/my-app/MyApp/obj/Release/MyApp.exe" to "/Users/tomityu/Gits/my-app/MyApp/bin/Release/MyApp.exe".
MyApp -> /Users/tomityu/Gits/my-app/MyApp/bin/Release/MyApp.exe
Copying file from "/Users/tomityu/Gits/my-app/MyApp/obj/Release/en/MyApp.resources.dll" to "/Users/tomityu/Gits/my-app/MyApp/bin/Release/en/MyApp.resources.dll".
Target _DetectSigningIdentity:
Detected signing identity:
Code Signing Key: "Developer ID Application: MYCOMPANY (7LM65QQ5VR)" (C34D25E1BBB78996C6A0257E78A87C103A320815)
Bundle Id: jp.mycompany
App Id: jp.mycompany
Target _CopyContentToBundle:
Creating directory '/Users/tomityu/Gits/my-app/MyApp/bin/Release/MyApp.app/Contents/Resources'
~
Copying file from '/Users/tomityu/Gits/my-app/MyApp/Resources/update.png' to '/Users/tomityu/Gits/my-app/MyApp/bin/Release/MyApp.app/Contents/Resources/update.png'
Target _CompileToNative:
/Library/Frameworks/Xamarin.Mac.framework/Versions/Current/bin/mmp @/Users/tomityu/Gits/my-app/MyApp/obj/Release/response-file.rsp
MMP : warning MM0079: The recommended Xcode version for Xamarin.Mac 6.20.2 is Xcode 11.6 or later. The current Xcode version (found in /Applications/Xcode.app/Contents/Developer) is 11.2.
MMP : warning MM2006: Native library 'libdl' was referenced but could not be found.
MMP : warning MM2009: Referenced by System.Data.SQLite.UnsafeNativeMethodsPosix.dlopen
Done building target "_CompileToNative" in project "MyApp.csproj".
Target CopyOurFiles:
This is us copying a file into resources!
Copying file from "/Users/tomityu/Gits/my-app/MyApp/NLog.config" to "/Users/tomityu/Gits/my-app/MyApp/bin/Release/MyApp.app/Contents/MonoBundle/NLog.config".
Target _CodesignNativeLibraries:
Tool /usr/bin/codesign execution started with arguments: -v --force --timestamp --sign C34D25E1BBB78996C6A0257E78A87C103A320815 --deep /Users/tomityu/Gits/my-app/MyApp/bin/Release/MyApp.app/Contents/MonoBundle/libmono-native.dylib
Tool /usr/bin/codesign execution started with arguments: -v --force --timestamp --sign C34D25E1BBB78996C6A0257E78A87C103A320815 --deep /Users/tomityu/Gits/my-app/MyApp/bin/Release/MyApp.app/Contents/MonoBundle/libMonoPosixHelper.dylib
Target _CodesignAppBundle:
Tool /usr/bin/codesign execution started with arguments: -v --force -o runtime --timestamp --sign C34D25E1BBB78996C6A0257E78A87C103A320815 --entitlements /Users/tomityu/Gits/my-app/MyApp/obj/Release/Entitlements.xcent --deep /Users/tomityu/Gits/my-app/MyApp/bin/Release/MyApp.app
Target _CodesignVerify:
/usr/bin/codesign --verify -vvvv --deep bin/Release/MyApp.app
bin/Release/MyApp.app: valid on disk
bin/Release/MyApp.app: satisfies its Designated Requirement
Done building project "MyApp.csproj".
Build succeeded.
Комментарии:
1. Можете ли вы просмотреть командную строку, которую MSBuild вызывает при подписании вашего приложения?
2. Спасибо за ваш комментарий! Добавлено в текст.
3. В вашем новом выводе говорится, что вы используете гораздо более старую версию XCode, чем рекомендуется (вы используете 11.2, но Xamarin требуется 11.6). Есть ли причина, по которой вы используете более старую версию? Возможно, обновление вашей версии XCode заставит его работать?
4. Я обновил версию Xcode до 11.6 и попробовал еще раз, но результат был тем же. Приложение выходит из строя на шаге (2).
5. Кто-нибудь может помочь мне решить эту проблему?