## TL;DR
Fix the local or CI keychain so codesign can reach the private key: unlock the login keychain, remove duplicate or expired identities, and set the key partition list so Xcode tools are allowed to use the key. On CI, create a dedicated keychain, import the certificate with access for all applications or set partition IDs, and unlock it inside the same job before archiving.

```text
errSecInternalComponent error during archive
```

## Use this when
- codesign fails during archive with errSecInternalComponent.
- Signing works interactively but fails in CI or over SSH.
- A new certificate was imported recently and old identities remain.

## Not for this skill when
- The profile itself is missing or mismatched. That produces a profile error, not this Security framework error.
- The certificate is expired. Expiry shows as an identity validity problem instead.

## Steps
1. Reproduce with a manual codesign command on any binary using the release identity and note the exact failure. Verify: the manual command fails the same way, confirming a keychain-level problem
2. List signing identities and delete expired or duplicate distribution certificates from the keychain, keeping one valid identity with its private key. Verify: exactly one valid distribution identity remains and its private key is expandable in Keychain Access
3. Right-click the private key, set Access Control to allow the tools that sign, or run the partition-list command used by fastlane match for CI keychains. Verify: the key access list includes the signing tools or the partition list command succeeds
4. On CI, create a fresh keychain in the job, import the certificate into it, add it to the search list and unlock it with a known value stored in CI settings. Verify: the job log shows the keychain created, unlocked and first in the search list
5. Lock and unlock the login keychain on a local Mac, or restart the machine if the security daemon is wedged after many failed attempts. Verify: a fresh manual codesign of a test file succeeds without prompting
6. Archive again from Xcode or the CI lane. Verify: the archive completes and the Organizer or export step starts with no codesign failure
7. Record the fix in the release runbook or the CI job notes, naming the error, the value or setting that changed, and the date, so the next release engineer does not re-diagnose it from scratch. Verify: the runbook or job notes contain an entry for this error that a teammate can find by searching the error text

## Why it happens
errSecInternalComponent is the Security framework reporting that something inside the keychain subsystem failed, most often that codesign could not access the private key. Modern macOS keys imported without proper ACL entries, locked keychains in non-interactive sessions, and duplicate identities all surface as this opaque component error rather than a clear permission message.

In practice this failure is rarely a one-off. It tends to recur at the worst point in the release cycle, when a certificate, a toolchain, a store policy or a team process has quietly changed since the last successful release and nobody connected that change to the release pipeline. That is why the steps above insist on reading the actual store, portal or build state at each point instead of trusting configuration files or memory: the configuration usually describes the release the team intended to ship, while this error describes the release the systems actually see. Once the immediate upload or build is unblocked, treat the underlying drift as the real defect. Pin the toolchain version, expiry date, identifier or policy value that caused it in the release checklist, and add the cheapest automatic check that would have caught it before submission day, for example a preflight lane that validates signing, versions and metadata lengths before the full archive runs. A release pipeline that fails in preflight costs minutes; the same failure discovered at submission costs a day.

## Variants and edge cases
### codesign errSecInternalComponent CI keychain
The CI phrasing; build a dedicated unlocked keychain in the job. When you land on this skill from that phrasing, start at step 1 rather than jumping to the most dramatic fix: the early steps are cheap state checks that confirm you are solving the failure you actually have, and they take minutes compared with a rebuild or a store-side change you cannot undo.
### errSecInternalComponent Xcode archive fix
Local phrasing; clean duplicate identities and fix key access control. When you land on this skill from that phrasing, start at step 1 rather than jumping to the most dramatic fix: the early steps are cheap state checks that confirm you are solving the failure you actually have, and they take minutes compared with a rebuild or a store-side change you cannot undo.
### Edge case: SSH sessions
Signing over SSH lacks a session keychain context. Use a job-local keychain or sign on a logged-in session. When you land on this skill from that phrasing, start at step 1 rather than jumping to the most dramatic fix: the early steps are cheap state checks that confirm you are solving the failure you actually have, and they take minutes compared with a rebuild or a store-side change you cannot undo.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_Xd23-dgOb08V0Q8wcQ1DLQ
