Skip to content

Support macOS signatures in nonofficial pipelines - #27976

Open
Justin Chung (jshigetomi) wants to merge 3 commits into
masterfrom
pipeline/nonofficial-macos-signatures
Open

Justin Chung (jshigetomi) wants to merge 3 commits into
masterfrom
pipeline/nonofficial-macos-signatures

Conversation

@jshigetomi

@jshigetomi Justin Chung (jshigetomi) commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

PR Summary

  • Accept Microsoft Developer ID signatures or ad-hoc CodeDirectories when validating Mach-O output from nonofficial coordinated builds.
  • Repair binaries that fail native verification with an ad-hoc signature on macOS package agents, then require strict codesign verification before packaging.
  • Keep official builds verification-only and continue requiring the production Developer ID signature.

PR Context

The nonofficial signing service can return a universal libpsl-native.dylib with only one architecture slice signed. The coordinated Windows check found an ad-hoc CodeDirectory, but native macOS verification rejected the unsigned x86_64 slice. Nonofficial package jobs now repair only binaries that fail verification and then verify every Mach-O binary with codesign --verify --deep --strict.

Validation:

  • Coordinated nonofficial build 715578 succeeded for x64 and arm64 signature validation.
  • Packages nonofficial run 715615 passed both x64 and arm64 macOS package jobs, including native strict signature verification.
  • The changed YAML and inline PowerShell parse successfully, PSScriptAnalyzer passes on the new helper, and local scenarios cover nonofficial repair and official verification-only behavior.

PR Checklist

Justin Chung and others added 3 commits September 4, 2026 13:13
Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 282853d0-d027-4558-9425-624a244cb9a3
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 282853d0-d027-4558-9425-624a244cb9a3
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 282853d0-d027-4558-9425-624a244cb9a3
Copilot AI lite review requested due to automatic review settings September 4, 2026 18:14
@jshigetomi
Justin Chung (jshigetomi) requested a review from a team as a code owner September 4, 2026 18:14
@jshigetomi Justin Chung (jshigetomi) added the CL-BuildPackaging Indicates that a PR should be marked as a build or packaging change in the Change Log label Sep 4, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The new macOS signing helper should align with established repo conventions for native command execution and verbosity control to ensure consistent diagnostics and log behavior.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds support for validating and (when allowed) repairing macOS Mach-O signatures in nonofficial coordinated-build packaging pipelines, while keeping official builds verification-only and requiring Developer ID signatures.

Changes:

  • Introduces Update-MacOSCodeSignature.ps1 to verify signatures and (for nonofficial builds) apply ad-hoc signing + strict re-verification.
  • Updates macOS packaging pipeline templates to pass OfficialBuild through and invoke the new helper.
  • Extends macOS coordinated-build signature validation to accept either the Microsoft Developer ID signature (official) or an ad-hoc CodeDirectory (nonofficial).
File summaries
File Description
tools/packaging/Update-MacOSCodeSignature.ps1 New helper to verify codesign output and repair nonofficial artifacts with ad-hoc signatures before packaging.
.pipelines/templates/stages/PowerShell-Packages-Stages.yml Plumbs OfficialBuild into macOS package template invocations.
.pipelines/templates/mac.yml Adjusts coordinated-build signature validation to accept Developer ID or ad-hoc CodeDirectory depending on officialness.
.pipelines/templates/mac-package-build.yml Adds OfficialBuild parameter and uses the new helper to apply/verify codesign on macOS package agents.
Review details

Suppressed comments (2)

tools/packaging/Update-MacOSCodeSignature.ps1:35

  • The initial codesign --verify call is handled via $LASTEXITCODE, which loses codesign stderr and is inconsistent with the repo’s Start-NativeExecution error handling. Wrapping verification in Start-NativeExecution (with a try/catch to allow the nonofficial repair path) provides better diagnostics without changing behavior.
    & codesign --verify --deep --strict --verbose=4 $binary.FullName
    if ($LASTEXITCODE -eq 0) {
        continue
    }

    if ($OfficialBuild) {
        throw "codesign verification failed for '$($binary.FullName)'."
    }

tools/packaging/Update-MacOSCodeSignature.ps1:54

  • The ad-hoc signing and post-sign verification use manual $LASTEXITCODE checks, which drops native output and duplicates error handling logic. Using Start-NativeExecution -VerboseOutputOnError here will surface codesign’s diagnostics in verbose logs on failure and keeps error handling consistent with the rest of the repo.
    & codesign @signArguments
    if ($LASTEXITCODE -ne 0) {
        throw "Ad-hoc codesign failed for '$($binary.FullName)'."
    }

    & codesign --verify --deep --strict --verbose=4 $binary.FullName
    if ($LASTEXITCODE -ne 0) {
        throw "codesign verification failed for '$($binary.FullName)' after applying an ad-hoc signature."
    }
  • Files reviewed: 4/4 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +17 to +18

$binaries = @(

# Nonofficial signing can leave only one slice of a universal binary signed.
# Re-signing on macOS applies an ad-hoc signature across every architecture.
Write-Verbose -Message "Applying an ad-hoc signature to '$($binary.FullName)' for the nonofficial package." -Verbose
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backport-7.4.x-Consider Backport-7.5.x-Consider Backport-7.6.x-Consider CL-BuildPackaging Indicates that a PR should be marked as a build or packaging change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants