You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The single-file bundler adds additional contents (the apps's dependencies) at the end of the host-binary. This violates the strict consistency checks performed by codesign tool in MAC.
This work item track the effort to make the MAC bundle amenable to signing.
You will get error message: main executable failed strict validation
If you add --no-strict option in codesign, you will get more detailed error messages:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate: the __LINKEDIT segment does not cover the end of the file (can't be processed) in: /Volumes/Data/temp/HelloDotNet/bin/Release/netcoreapp3.0/osx.10.12-x64/publish/MacOS/HelloDotNet
/Volumes/Data/temp/HelloDotNet/bin/Release/netcoreapp3.0/osx.10.12-x64/publish/MacOS/HelloDotNet: the codesign_allocate helper tool cannot be found or used
We cannot just fixup the size on disk, we also need to increase the vmsize of __LINKEDIT section (that is, the size as loaded). This means that the entire single-file is loaded by the OS loader when the program starts up.
In the current scheme of things, this leads to loading all the bundle contents twice, which is wasteful
When bundle contents are processed directly from disk, I think this scheme can be used more natuarally.
With the above change, the __LINKEDIT section is loaded, and the program run successfully. However, the codesign tool is still not happy because it sees that there's no __LINKEDIT data that's referring to the content at the end of the section. Adding a reference to this data involves complex fixup with possible cascading effects for VM-addresses. The fixup for this is rather brittle without support from the native linker.
After dotnet/core-setup#8590, I have a better understanding of the file layout; I'll try out another fix for this issue to extend the __LINKEDIT section to cover the single-exe metadata.
Reacted by Pavel Khrulev, PavelAnfimov and Marc Wils
The fix is somewhat fragile in the long run, because it relies on the current behavior and checks implemented in codesign tool. It may break if the tool introduces more checks (ex: check that all bytes in the string table are referenced).
The reliable way to generate an image is to use the native tool chain, but this involves substantial support in and beyond the .net core SDK.
Hey guys. Not sure how to solve my problem, even after @VSadov fix.
I have a singleFile bundle inside another App and when I sign the whole contents of the App it always fails in the singleFile bundle binary with the mentioned error. I'm failing to understand how to fix the issue...
@Jmales - I am a bit confused. Did you have a problem signing a .NET 6.0 singlefile app?
I wonder what was the SDK build number. The fix is fairly recent and it takes some time for a fix to make it from the development branch to the published installers. Maybe the fix was not there yet.
Activity
swaroop-sridhar commentedon Jul 5, 2019
Here's an attempt to fixup the __LINKEDIT section to accommodate the SingleFile blob at the end of the file: https://github.com/dotnet/core-setup/compare/master...swaroop-sridhar:mac?expand=1
There are some downsides to doing this fixup:
MarcWils commentedon Jul 17, 2019
Any update about when this will be fixed or available in a preview release?
We want to distribute a .NET Core 3.0 (preview6) app on MacOS. Code siging is mandatory.
Is there any workaround to publish a signed .NET Core MacOS application?
pavelkhrulev commentedon Oct 21, 2019
@MarcWils Did you find some way to publish signed MacOS application?
swaroop-sridhar commentedon Oct 21, 2019
@MarcWils @pavelkhrulev
After dotnet/core-setup#8590, I have a better understanding of the file layout; I'll try out another fix for this issue to extend the __LINKEDIT section to cover the single-exe metadata.
MarcWils commentedon Oct 22, 2019
No I didn't. We reverted to building a native macOS app.
Single-file: Facilitate signing on mac
swaroop-sridhar commentedon Nov 2, 2019
The MAC codesign tool places several restrictions on the layout
__LINKEDITsegment must be the last one__LINKEDITsegment must cover the end of the file__LINKEDITsegment are used by other linkage commands (ex: symbol/string table, dynamic load information etc)In order to circumvent these restrictions, I implemented a change that:
__LINKEDITsegment to include the bundle-data(that is, the bundle-data appear as strings to the loader/codesign tool).
This method has certain limitations:
Here's a change that implements the fix: https://github.com/dotnet/core-setup/compare/master...swaroop-sridhar:macsign?expand=1
swaroop-sridhar commentedon Nov 2, 2019
The fix is somewhat fragile in the long run, because it relies on the current behavior and checks implemented in
codesigntool. It may break if the tool introduces more checks (ex: check that all bytes in the string table are referenced).The reliable way to generate an image is to use the native tool chain, but this involves substantial support in and beyond the .net core SDK.
swaroop-sridhar commentedon Nov 2, 2019
CC: @jeffschwMSFT @jkotas
swaroop-sridhar commentedon Nov 2, 2019
CC: @noahfalk
rlalance commentedon Feb 6, 2020
ok, this is going to block distribution of the app. Not cool.
richardlalancetteyoui commentedon Feb 6, 2020
What is my alternative to start sharing my dotnet 3.1 application with my clients?
32 remaining items
vitek-karas commentedon Nov 16, 2020
Related work in mono: mono/mono#17881
VSadov commentedon Jan 14, 2021
Fixed in #46558
Jmales commentedon Jan 18, 2021
Hey guys. Not sure how to solve my problem, even after @VSadov fix.
I have a singleFile bundle inside another App and when I sign the whole contents of the App it always fails in the singleFile bundle binary with the mentioned error. I'm failing to understand how to fix the issue...
vitek-karas commentedon Jan 18, 2021
As mentioned above by @VSadov this has been fixed for .NET 6 here: #46558. As far as I know we don't have plans to try to backport this to .NET 5.
Jmales commentedon Jan 18, 2021
This single-file was our workaround to: #46990
Everything worked well, except for the signing of the SingleFile binary/bundle. Now we have no idea on how to tackle the problem at hands.
VSadov commentedon Jan 20, 2021
@Jmales - I am a bit confused. Did you have a problem signing a .NET 6.0 singlefile app?
I wonder what was the SDK build number. The fix is fairly recent and it takes some time for a fix to make it from the development branch to the published installers. Maybe the fix was not there yet.
rlalance commentedon Jan 21, 2021
Really looking for this. This was a pretty major roadblock for my team.
agocke commentedon Jan 21, 2021
Note that at the moment we have no plans to backport the fix to 5.0 -- are you OK with relying on a preview version or waiting for 6.0?
VSadov commentedon Feb 1, 2021
Recent 6.0 and 6.0.preview1 SDK builds should contain the fix.
@richardlalancette - could you check if the fix is sufficient for your scenario?
rlalance commentedon Feb 1, 2021
I'm still on .net 5.0 here.
Is the 6.0 preview SDK good enough for production apps?