Skip to content

[release/13.2] Backport PR #16053: Fix macOS signing, permissions, cert trust, and CI verification#16215

Merged
joperezr merged 9 commits intorelease/13.2from
copilot/backport-pr-16053-release-13-2
Apr 15, 2026
Merged

[release/13.2] Backport PR #16053: Fix macOS signing, permissions, cert trust, and CI verification#16215
joperezr merged 9 commits intorelease/13.2from
copilot/backport-pr-16053-release-13-2

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 15, 2026

Description

Backport of #16053 to the release/13.2 branch.

Changes

  • macOS JIT entitlements: Add aspire-managed-entitlements.plist with CoreCLR JIT and library loading entitlements, and ad-hoc codesign step before Arcade signing.
  • Execute permissions: Restore the execute bit on aspire-managed after MicroBuild signing resets Unix file permissions.
  • Non-interactive cert trust: Skip certificate trust operations on macOS/Windows in non-interactive mode (CI) to avoid blocking prompts. Linux trust proceeds since it's non-interactive by nature.
  • CLI archive verification scripts: Add verify-cli-archive.sh (Linux/macOS) and verify-cli-archive.ps1 (Windows) that validate signed CLI archives by extracting, running aspire --version, and aspire new.
  • CI pipeline integration: Wire verification scripts into build_sign_native.yml and BuildAndTest.yml.
  • PR feedback: Restore mockable isNonInteractiveTrustSupported parameter for testability, fix scripts.

Conflict Resolution

The following conflicts were resolved during the backport:

  • ICertificateToolRunner / NativeCertificateToolRunner: Added EnsureHttpCertificateExists() method (existed on main but not release/13.2). This method creates a dev cert without trusting it, used in non-interactive mode.
  • CertificateService constructor: Added ICliHostEnvironment parameter (already registered in DI on release/13.2) and optional isNonInteractiveTrustSupported delegate.
  • CliTestHelper.cs: Updated default CertificateServiceFactory to inject ICliHostEnvironment.
  • TestCertificateToolRunner (TestServices/): Added EnsureHttpCertificateExists implementation to satisfy the updated interface.
  • IsSuccessfulEnsureResult helper method added to CertificateService.

Fixes #16043

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?

radical and others added 7 commits April 15, 2026 20:24
macOS hardened runtime blocks CoreCLR JIT (W^X memory mapping) unless the
binary carries com.apple.security.cs.allow-jit and related entitlements.
MicroBuild's MacDeveloperHardenWithNotarization signing preserves
entitlements from a prior ad-hoc signature, so we codesign with the
entitlements plist before Arcade signing.

This follows the same pattern used by dotnet/sdk for Roslyn managed
binaries (roslyn-entitlements.plist).

Fixes #16043

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Co-authored-by: joperezr <13854455+joperezr@users.noreply.github.com>
MicroBuild rewrites the binary file during signing, which resets Unix
file permissions to the default umask (typically 644). The execute bit
must be restored before CreateLayout packs the binary into the CLI
archive. Without this, macOS and Linux archives contain a non-executable
aspire-managed binary.

Fixes #16043

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Co-authored-by: joperezr <13854455+joperezr@users.noreply.github.com>
Backport of fbdac8a with conflict resolution:
- Added EnsureHttpCertificateExists() to ICertificateToolRunner and NativeCertificateToolRunner
- Added ICliHostEnvironment parameter to CertificateService constructor
- Updated CliTestHelper default CertificateServiceFactory to pass ICliHostEnvironment
- Added IsSuccessfulEnsureResult helper method
- Added TestCliHostEnvironment and new non-interactive test cases

Co-authored-by: joperezr <13854455+joperezr@users.noreply.github.com>
Add verify-cli-archive.sh (Linux/macOS) and verify-cli-archive.ps1
(Windows) scripts that validate a signed CLI archive by:
  1. Extracting the archive to a temp location
  2. Running 'aspire --version' to verify the binary executes
  3. Running 'aspire new aspire-starter' to test bundle self-extraction
     and project creation (exercises aspire-managed)
  4. Cleaning up temp state (backs up and restores ~/.aspire)

These scripts will be wired into the CI pipeline to catch signing and
permissions regressions before they reach users.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Co-authored-by: joperezr <13854455+joperezr@users.noreply.github.com>
Add post-signing verification steps to both build_sign_native.yml
(macOS/Linux) and BuildAndTest.yml (Windows) that run the verification
scripts after the CLI archives are built and signed.

Verification runs for RIDs that can fully execute on the build agent:
  - macOS (Apple Silicon): osx-arm64 only
  - Linux (amd64): linux-x64 only
  - Windows: win-x64

This ensures that signing/permissions regressions (like the ones fixed
in this PR) are caught during the official build before release.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Co-authored-by: joperezr <13854455+joperezr@users.noreply.github.com>
- Restore mockable isNonInteractiveTrustSupported parameter in
  CertificateService for testability (was Func<bool> isWindows)
- Fix cert tests to use explicit mocks instead of OS-dependent assertions
- Move backup dir into VERIFY_TMPDIR to avoid orphaned temp dirs
- Fix BuildAndTest.yml comment to match actual script behavior

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Co-authored-by: joperezr <13854455+joperezr@users.noreply.github.com>
The TestCertificateToolRunner in TestServices/ also needs to implement the
EnsureHttpCertificateExists method added to ICertificateToolRunner as part
of the backport.

Co-authored-by: joperezr <13854455+joperezr@users.noreply.github.com>
Keep only macOS entitlements plist and build_sign_native.yml
signing changes. Remove CI verification scripts, cert trust
changes, and related test updates.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 15, 2026

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 16215

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 16215"

@joperezr joperezr marked this pull request as ready for review April 15, 2026 21:21
Copilot AI review requested due to automatic review settings April 15, 2026 21:21
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Backports fixes to the release/13.2 branch to address macOS aspire-managed runtime failures after signing (missing hardened-runtime/JIT entitlements and lost execute permissions), and adds CI-side verification of produced CLI archives.

Changes:

  • Add a macOS ad-hoc codesign step for aspire-managed with CoreCLR JIT entitlements prior to Arcade/MicroBuild signing.
  • Restore the Unix execute bit on aspire-managed after signing so packaged archives contain an executable binary.
  • Add a post-build step to verify the produced CLI archive can execute and run basic commands (aspire --version, aspire new) on supported agent/RID combinations.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
eng/pipelines/templates/build_sign_native.yml Adds macOS ad-hoc signing with entitlements, post-sign chmod, and a signed-archive verification step.
eng/aspire-managed-entitlements.plist Introduces the macOS entitlements required for CoreCLR JIT and library loading under hardened runtime.

- script: >-
codesign --sign - --force
--entitlements $(Build.SourcesDirectory)/eng/aspire-managed-entitlements.plist
$(Build.SourcesDirectory)/artifacts/bin/Aspire.Managed/Release/net10.0/${{ targetRid }}/publish/aspire-managed
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

The path used for the ad-hoc codesign step hard-codes both the build configuration (Release) and TFM (net10.0). This makes the pipeline brittle (it will break if _BuildConfig changes or if Aspire.Managed’s TFM changes). Consider locating aspire-managed via $(_BuildConfig) and/or a globbed TFM segment (consistent with the $(ArtifactsBinDir)Aspire.Managed/**/publish/aspire-managed pattern used in eng/Signing.props).

Suggested change
$(Build.SourcesDirectory)/artifacts/bin/Aspire.Managed/Release/net10.0/${{ targetRid }}/publish/aspire-managed
$(Build.SourcesDirectory)/artifacts/bin/Aspire.Managed/$(_BuildConfig)/*/${{ targetRid }}/publish/aspire-managed

Copilot uses AI. Check for mistakes.
# CreateLayout packs the binary into the bundle archive.
- ${{ if and(eq(parameters.codeSign, true), ne(parameters.agentOs, 'windows')) }}:
- script: >-
chmod +x $(Build.SourcesDirectory)/artifacts/bin/Aspire.Managed/Release/net10.0/${{ targetRid }}/publish/aspire-managed
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

This chmod step also hard-codes Release/net10.0 in the publish output path, which can get out of sync with $(_BuildConfig) used earlier and with future TFM changes. Use $(_BuildConfig) (and avoid embedding the TFM in the path, e.g., by globbing the TFM segment) so the step consistently targets the actual publish output.

Suggested change
chmod +x $(Build.SourcesDirectory)/artifacts/bin/Aspire.Managed/Release/net10.0/${{ targetRid }}/publish/aspire-managed
chmod +x $(Build.SourcesDirectory)/artifacts/bin/Aspire.Managed/$(_BuildConfig)/*/${{ targetRid }}/publish/aspire-managed

Copilot uses AI. Check for mistakes.
<!-- Required for CoreCLR JIT compilation under hardened runtime -->
<key>com.apple.security.cs.allow-jit</key>
<true/>
<!-- Required for loading .NET runtime libraries -->
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

The comment for com.apple.security.cs.allow-unsigned-executable-memory appears inaccurate: this entitlement is for allowing unsigned executable memory mappings (often needed alongside JIT), not specifically for loading runtime libraries. Please update the comment to reflect the actual purpose so future maintenance doesn’t rely on misleading documentation.

Suggested change
<!-- Required for loading .NET runtime libraries -->
<!-- Required for unsigned executable memory mappings used by JIT-generated code -->

Copilot uses AI. Check for mistakes.
Restore BuildAndTest.yml wiring and verify-cli-archive scripts
to validate signed archives work correctly after signing.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor

🎬 CLI E2E Test Recordings — 53 recordings uploaded (commit 9b9c511)

View recordings
Test Recording
AddPackageInteractiveWhileAppHostRunningDetached ▶️ View Recording
AddPackageWhileAppHostRunningDetached ▶️ View Recording
AgentCommands_AllHelpOutputs_AreCorrect ▶️ View Recording
AgentInitCommand_DefaultSelection_InstallsSkillOnly ▶️ View Recording
AgentInitCommand_MigratesDeprecatedConfig ▶️ View Recording
AspireAddPackageVersionToDirectoryPackagesProps ▶️ View Recording
AspireUpdateRemovesAppHostPackageVersionFromDirectoryPackagesProps ▶️ View Recording
Banner_DisplayedOnFirstRun ▶️ View Recording
Banner_DisplayedWithExplicitFlag ▶️ View Recording
CertificatesClean_RemovesCertificates ▶️ View Recording
CertificatesTrust_WithNoCert_CreatesAndTrustsCertificate ▶️ View Recording
CertificatesTrust_WithUntrustedCert_TrustsCertificate ▶️ View Recording
ConfigSetGet_CreatesNestedJsonFormat ▶️ View Recording
CreateAndRunAspireStarterProject ▶️ View Recording
CreateAndRunAspireStarterProjectWithBundle ▶️ View Recording
CreateAndRunEmptyAppHostProject ▶️ View Recording
CreateAndRunJsReactProject ▶️ View Recording
CreateAndRunPythonReactProject ▶️ View Recording
CreateAndRunTypeScriptEmptyAppHostProject ▶️ View Recording
CreateAndRunTypeScriptStarterProject ▶️ View Recording
CreateStartAndStopAspireProject ▶️ View Recording
CreateTypeScriptAppHostWithViteApp ▶️ View Recording
DescribeCommandResolvesReplicaNames ▶️ View Recording
DescribeCommandShowsRunningResources ▶️ View Recording
DetachFormatJsonProducesValidJson ▶️ View Recording
DoctorCommand_DetectsDeprecatedAgentConfig ▶️ View Recording
DoctorCommand_WithSslCertDir_ShowsTrusted ▶️ View Recording
DoctorCommand_WithoutSslCertDir_ShowsPartiallyTrusted ▶️ View Recording
GlobalMigration_HandlesCommentsAndTrailingCommas ▶️ View Recording
GlobalMigration_HandlesMalformedLegacyJson ▶️ View Recording
GlobalMigration_PreservesAllValueTypes ▶️ View Recording
GlobalMigration_SkipsWhenNewConfigExists ▶️ View Recording
GlobalSettings_MigratedFromLegacyFormat ▶️ View Recording
InitTypeScriptAppHost_AugmentsExistingViteRepoAtRoot ▶️ View Recording
InvalidAppHostPathWithComments_IsHealedOnRun ▶️ View Recording
LegacySettingsMigration_AdjustsRelativeAppHostPath ▶️ View Recording
LogsCommandShowsResourceLogs ▶️ View Recording
PsCommandListsRunningAppHost ▶️ View Recording
PsFormatJsonOutputsOnlyJsonToStdout ▶️ View Recording
PublishWithDockerComposeServiceCallbackSucceeds ▶️ View Recording
RestoreGeneratesSdkFiles ▶️ View Recording
RunFromParentDirectory_UsesExistingConfigNearAppHost ▶️ View Recording
RunWithMissingAwaitShowsHelpfulError ▶️ View Recording
SecretCrudOnDotNetAppHost ▶️ View Recording
SecretCrudOnTypeScriptAppHost ▶️ View Recording
StagingChannel_ConfigureAndVerifySettings_ThenSwitchChannels ▶️ View Recording
StartAndWaitForTypeScriptSqlServerAppHostWithNativeAssets ▶️ View Recording
StopAllAppHostsFromAppHostDirectory ▶️ View Recording
StopAllAppHostsFromUnrelatedDirectory ▶️ View Recording
StopNonInteractiveMultipleAppHostsShowsError ▶️ View Recording
StopNonInteractiveSingleAppHost ▶️ View Recording
StopWithNoRunningAppHostExitsSuccessfully ▶️ View Recording
TypeScriptAppHostWithProjectReferenceIntegration ▶️ View Recording

📹 Recordings uploaded automatically from CI run #24480114762

@joperezr joperezr merged commit 0220fd3 into release/13.2 Apr 15, 2026
256 checks passed
@github-actions github-actions Bot added this to the 13.2.x milestone Apr 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants