Skip to content

Add macOS binary code signing and package notarization#27347

Merged
andyleejordan merged 2 commits into
masterfrom
andyleejordan/apple-notarization
May 1, 2026
Merged

Add macOS binary code signing and package notarization#27347
andyleejordan merged 2 commits into
masterfrom
andyleejordan/apple-notarization

Conversation

@andyleejordan
Copy link
Copy Markdown
Member

@andyleejordan andyleejordan commented Apr 23, 2026

PR Summary

Apple notarized installer! Resolves #10874, #27262, #23974, #24088, #19363, #10141, #16467, #12139, #18353, #15203, #4547, #2546, #1881, #19053 etc.

PR Context

We still need to apply the template signing so that Guardian tasks pass and so that script files are signed. After doing what's essentially Windows signing, we sign and harden the binaries for macOS. Then we do the same for the PKG installer, and finally notarize it. The ESRP signing service requires a zip of files for Apple signing at all stages. Now that we can use it via the OneBranch signing task we no longer need the service connection or variable group that was trying to set it up. Notarization requires the BundleId from Get-MacOSPackageIdentifierInfo.

Uses codesign in the macOS build step to apply entitlements from a plist. This is required for the hardened runtime (which is required for notarization).

See: https://learn.microsoft.com/en-us/dotnet/core/install/macos-notarization-issues#default-entitlements

PR Checklist

@andyleejordan andyleejordan force-pushed the andyleejordan/apple-notarization branch from cfb3384 to 4a6787b Compare April 23, 2026 20:15
@andyleejordan andyleejordan added OS-macOS Compliance Related to compliance requirements CL-BuildPackaging Indicates that a PR should be marked as a build or packaging change in the Change Log labels Apr 23, 2026
@andyleejordan andyleejordan marked this pull request as ready for review April 23, 2026 21:33
@andyleejordan andyleejordan requested review from a team and jshigetomi as code owners April 23, 2026 21:33
Copilot AI review requested due to automatic review settings April 23, 2026 21:33
@andyleejordan
Copy link
Copy Markdown
Member Author

There is an available package powershell-7.9.99-preview.19-osx-arm64.pkg on the internal pipeline for other Microsoft devs to smoke test. To me it's so far, so good!

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

This PR adds macOS hardened-runtime signing and Apple notarization steps to the packaging pipelines, introducing an entitlements plist applied during the macOS build and extending the pipeline signing flow to Apple-sign Mach-O binaries and notarize the PKG installer.

Changes:

  • Export Get-MacOSPackageIdentifierInfo from the packaging module and use it to compute the Bundle ID for notarization.
  • Add a macOS entitlements plist and apply it via codesign during the macOS build output generation.
  • Add OneBranch Apple signing (Mach-O + PKG) and PKG notarization steps, plus a verification step for Apple code signing.

Reviewed changes

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

File Description
tools/packaging/packaging.psd1 Exports Get-MacOSPackageIdentifierInfo for use by pipeline scripts.
assets/macos-entitlements.plist Adds entitlements used to enable hardened runtime signing for macOS binaries.
.pipelines/templates/mac.yml Applies entitlements to pwsh during build and adds Apple-signing steps for the signed output.
.pipelines/templates/mac-package-build.yml Verifies Apple signing on binaries, sets BundleId output, signs/notarizes PKG zips, and extracts notarized PKGs.

Comment thread .pipelines/templates/mac-package-build.yml
Comment thread .pipelines/templates/mac-package-build.yml
Comment thread .pipelines/templates/mac-package-build.yml
@andyleejordan andyleejordan force-pushed the andyleejordan/apple-notarization branch from 4a6787b to 3b0972e Compare April 23, 2026 22:05
@andyleejordan
Copy link
Copy Markdown
Member Author

andyleejordan commented Apr 24, 2026

Before anyone says to remove the key code, that is already public info thanks to us, VS Code, Kiota, Azure Functions, Mono, for some reason Haystack etc.: https://github.com/search?type=code&q=CP-401337-Apple

(But in #27354 I finish the started work to migrate all our CP codes to a variable group for "defense in depth" purposes.)

@andyleejordan
Copy link
Copy Markdown
Member Author

And yes there really are what amounts to five signing steps for this process:

  1. "signing" binaries for macOS to apply entitlements (no real signature)
  2. signing .NET binaries with Authenticode (only matters for Windows but compliance necessitates it)
  3. signing binaries for macOS with actual signature
  4. signing PKG with those binaries inside it for macOS
  5. notarizing PKG with Apple (another type of signing)

andyleejordan and others added 2 commits April 24, 2026 15:39
We still need to apply the template signing so that Guardian tasks pass
and so that script files are signed. After doing what's essentially
Windows signing, we sign and harden the binaries for macOS. Then we do
the same for the PKG installer, and finally notarize it. The ESRP
signing service requires a zip of files for Apple signing at all stages.
Now that we can use it via the OneBranch signing task we no longer need
the service connection or variable group that was trying to set it up.
Notarization requires the BundleId from Get-MacOSPackageIdentifierInfo.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Uses codesign in the macOS build step to apply entitlements from a plist.
This is required for the hardened runtime (which is required for notarization).

See: https://learn.microsoft.com/en-us/dotnet/core/install/macos-notarization-issues#default-entitlements

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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

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

Comment thread assets/macos-entitlements.plist
Comment thread .pipelines/templates/mac.yml
Comment thread .pipelines/templates/mac-package-build.yml
@andyleejordan andyleejordan force-pushed the andyleejordan/apple-notarization branch from 5a0f767 to 12a9df7 Compare May 1, 2026 20:33
@andyleejordan andyleejordan enabled auto-merge (squash) May 1, 2026 20:36
@andyleejordan andyleejordan disabled auto-merge May 1, 2026 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backport-7.4.x-Migrated Backport-7.5.x-Approved Backport-7.6.x-Done CL-BuildPackaging Indicates that a PR should be marked as a build or packaging change in the Change Log Compliance Related to compliance requirements OS-macOS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

macOS package sometimes is blocked on macOS

6 participants