Skip to content

[msbuild] Show a helpful error when codesign fails with errSecInternalComponent. Fixes #26183. - #26189

Merged
rolfbjarne merged 3 commits into
mainfrom
dev/rolf/issue-26183-codesign-fails-with-errsecinternalcompon-598edf
Jul 23, 2026
Merged

[msbuild] Show a helpful error when codesign fails with errSecInternalComponent. Fixes #26183.#26189
rolfbjarne merged 3 commits into
mainfrom
dev/rolf/issue-26183-codesign-fails-with-errsecinternalcompon-598edf

Conversation

@rolfbjarne

Copy link
Copy Markdown
Member

When you build/deploy an app over SSH, the login keychain is typically locked (there's no GUI login session to unlock it). In that state codesign can't access the signing identity's private key and fails with the cryptic Security-framework error errSecInternalComponent, with no hint about what's actually wrong.

This detects that specific error in the Codesign MSBuild task and emits an additional, actionable error telling the user the keychain is likely locked and how to unlock it:

Codesign failed with 'errSecInternalComponent'. This usually means the keychain is locked, which is common when building over SSH. Unlock the keychain first, for example by running 'security unlock-keychain ~/Library/Keychains/login.keychain-db'.

The original codesign error is still shown as well, since errSecInternalComponent isn't always caused by a locked keychain.

Fixes #26183

🤖 Pull request created by Copilot

rolfbjarne and others added 2 commits July 20, 2026 14:16
…lComponent.

When building over SSH, the login keychain is typically locked, and codesign
fails with the cryptic 'errSecInternalComponent' error. Detect this specific
error and emit an additional, actionable message telling the user to unlock
the keychain first.

Fixes #26183.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 4792ee55-551d-4464-9466-65bd0d0f2fbc
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 4792ee55-551d-4464-9466-65bd0d0f2fbc
Copilot AI review requested due to automatic review settings July 20, 2026 12:47
@rolfbjarne
rolfbjarne requested a review from mauroa as a code owner July 20, 2026 12:47

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.

Pull request overview

This PR improves the MSBuild Codesign task’s diagnostics by detecting the errSecInternalComponent codesign failure and emitting an additional actionable message that points users to unlocking their keychain (a common cause when building over SSH).

Changes:

  • Detect errSecInternalComponent in codesign stderr and log an additional hint to unlock the login keychain.
  • Add localized resource string E7184 containing the new actionable error message.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
msbuild/Xamarin.MacDev.Tasks/Tasks/Codesign.cs Adds detection of errSecInternalComponent and emits a dedicated hint error.
msbuild/Xamarin.Localization.MSBuild/MSBStrings.resx Adds localized string E7184 for the new hint message.

Comment thread msbuild/Xamarin.MacDev.Tasks/Tasks/Codesign.cs
dalexsoto
dalexsoto previously approved these changes Jul 20, 2026
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

@dalexsoto

Copy link
Copy Markdown
Member

/azp run xamarin-macios-sim-pr-tests

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@vs-mobiletools-engineering-service2

This comment has been minimized.

@dalexsoto

Copy link
Copy Markdown
Member

/azp run xamarin-macios-sim-pr-tests

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@vs-mobiletools-engineering-service2

This comment has been minimized.

@dalexsoto

Copy link
Copy Markdown
Member

/azp run xamarin-macios-sim-pr-tests

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

…nce, use ordinal matching.

Codesign.Sign runs for multiple items and in parallel, so the errSecInternalComponent
hint could be logged many times. Guard it with an Interlocked flag so it's only logged
once per task invocation, and match the error string using an ordinal comparison for
consistent behavior across target frameworks.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 4792ee55-551d-4464-9466-65bd0d0f2fbc
@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ API diff for current PR / commit

NET (empty diffs)

✅ API diff vs stable

NET (empty diffs)

ℹ️ Generator diff

Generator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes)

Pipeline on Agent
Hash: c5c8cc181363bd4eda1a715d489af5585ffaa978 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

🚀 [CI Build #c5c8cc1] Test results 🚀

Test results

✅ All tests passed on VSTS: test results.

🎉 All 203 tests passed 🎉

Tests counts

✅ assembly-processing: All 1 tests passed. Html Report (VSDrops) Download
✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (iOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (MacCatalyst): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (macOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (Multiple platforms): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (tvOS): All 1 tests passed. Html Report (VSDrops) Download
✅ framework: All 2 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 4 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ generator: All 5 tests passed. Html Report (VSDrops) Download
✅ interdependent-binding-projects: All 4 tests passed. Html Report (VSDrops) Download
✅ introspection: All 4 tests passed. Html Report (VSDrops) Download
✅ linker (iOS): All 15 tests passed. Html Report (VSDrops) Download
✅ linker (MacCatalyst): All 15 tests passed. Html Report (VSDrops) Download
✅ linker (macOS): All 21 tests passed. Html Report (VSDrops) Download
✅ linker (tvOS): All 15 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 19 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 18 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 19 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 19 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ sharpie: All 1 tests passed. Html Report (VSDrops) Download
✅ windows: All 3 tests passed. Html Report (VSDrops) Download
✅ xcframework: All 4 tests passed. Html Report (VSDrops) Download
✅ xtro: All 1 tests passed. Html Report (VSDrops) Download

macOS tests

✅ Tests on macOS Monterey (12): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Ventura (13): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Sonoma (14): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Sequoia (15): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Tahoe (26): All 5 tests passed. Html Report (VSDrops) Download

Linux Build Verification

Linux build succeeded

Pipeline on Agent
Hash: c5c8cc181363bd4eda1a715d489af5585ffaa978 [PR build]

@rolfbjarne
rolfbjarne merged commit 445d38d into main Jul 23, 2026
56 checks passed
@rolfbjarne
rolfbjarne deleted the dev/rolf/issue-26183-codesign-fails-with-errsecinternalcompon-598edf branch July 23, 2026 05:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

codesign fails with errSecInternalComponent when run through ssh, because keychain is not unlocked yet

5 participants