Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use managed Mach-O signer on non-Mac hosts #45019

Merged
merged 10 commits into from
Jan 2, 2025

Conversation

jtschuster
Copy link
Member

In dotnet/runtime#108992, we added a managed ad-hoc signer that's used in HostWriter.CreateAppHost. This PR enables it to be used in the sdk when publishing for osx on non-Mac hosts so that developers can distribute an ad-hoc signed binary without using a Mac.

Tests on all platforms ensure that there is a load command with the LC_CODE_SIGNATURE command type in the Mach-O binary. On MacOS, codesign is used to fully validate the signature in addition.

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged Request triage from a team member label Nov 21, 2024
Copy link

I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label.

1 similar comment
Copy link

I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label.

test/Microsoft.NET.Build.Tests/AppHostTests.cs Outdated Show resolved Hide resolved
test/Microsoft.NET.Build.Tests/AppHostTests.cs Outdated Show resolved Hide resolved
test/Microsoft.NET.Build.Tests/AppHostTests.cs Outdated Show resolved Hide resolved
@@ -509,5 +507,62 @@ private static bool IsPE32(string path)
return reader.PEHeaders.PEHeader.Magic == PEMagic.PE32;
}
}

// Reads the Mach-O load commands and returns true if an LC_CODE_SIGNATURE command is found, otherwise returns false
static bool HasMachOSignatureLoadCommand(FileInfo file)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't matter for this change, but we may want this in a shared test helper so that we can add cross-platform checks for single-file publish with signing after dotnet/runtime#110417 goes in.

test/Microsoft.NET.Build.Tests/AppHostTests.cs Outdated Show resolved Hide resolved
test/Microsoft.NET.Build.Tests/AppHostTests.cs Outdated Show resolved Hide resolved
@jtschuster
Copy link
Member Author

/ba-g test failures are all known

@jtschuster jtschuster merged commit abe7d29 into dotnet:main Jan 2, 2025
35 of 37 checks passed
jtschuster added a commit that referenced this pull request Jan 2, 2025
In dotnet/runtime#108992, we added a managed ad-hoc signer that's used in HostWriter.CreateAppHost. This PR enables it to be used in the sdk when publishing for osx on non-Mac hosts so that developers can distribute an ad-hoc signed binary without using a Mac.

Tests on all platforms ensure that there is a load command with the LC_CODE_SIGNATURE command type in the Mach-O binary. On MacOS, codesign is used to fully validate the signature in addition.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Host untriaged Request triage from a team member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants