Add macOS binary code signing and package notarization#27347
Conversation
cfb3384 to
4a6787b
Compare
|
There is an available package |
There was a problem hiding this comment.
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-MacOSPackageIdentifierInfofrom the packaging module and use it to compute the Bundle ID for notarization. - Add a macOS entitlements plist and apply it via
codesignduring 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. |
4a6787b to
3b0972e
Compare
|
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.) |
|
And yes there really are what amounts to five signing steps for this process:
|
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>
3b0972e to
12a9df7
Compare
5a0f767 to
12a9df7
Compare
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
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright header