transport/roots/system: fix darwin/arm64 build by removing dead armx stub#1438
Open
lukevalenta wants to merge 1 commit into
Open
transport/roots/system: fix darwin/arm64 build by removing dead armx stub#1438lukevalenta wants to merge 1 commit into
lukevalenta wants to merge 1 commit into
Conversation
…stub
After this fix, cfssl will compile on Apple Silicon using the
'transport/roots/system/root_cgo_darwin.go' path. The 'armx' path seems
to never have been functional. The rest of this description was
generated w/ AI assistance. It's a bit wordy, but the context seems
useful so I'm leaving it.
`transport/roots/system/root_darwin_armx.go` defined a void
`initSystemRoots()` that referenced identifiers (`systemRoots`,
`NewCertPool`, `AppendCertsFromPEM`) that don't exist in the package
and that doesn't match `root.go`'s caller signature. As a result, the
package fails to compile on `darwin/arm64` (Apple Silicon) with cgo
enabled:
root.go:42:11: initSystemRoots() (no value) used as value
root_darwin_armx.go:15:2: undefined: systemRoots
root_darwin_armx.go:15:16: undefined: NewCertPool
root_darwin_armx.go:16:2: undefined: systemRoots
Origin of the bug: `root_darwin_armx.go` was checked in on 2015-11-04
(0fd8a23) with this signature already wrong. The accompanying
generator `root_darwin_arm_gen.go` (deleted in the same commit)
emitted a header that would have produced the correct
`initSystemRoots() []*x509.Certificate { ... return roots }` shape,
but the generated file committed alongside the generator's deletion
was clearly produced by an earlier version of the tool and never
re-run. The pattern `systemRoots = NewCertPool()` matches the
internal API of `crypto/x509` circa Go ~1.5. The bug went unnoticed
for ~5 years because `darwin/arm64` wasn't a common build target
until Apple Silicon launched in late 2020; the first user report
(cloudflare#1235) is from August 2022.
The file existed to embed a static blob of Apple-published iOS root
certificates because, in 2015, the cgo path's
`SecKeychainItemExport` API was deprecated on iOS and there was no
way to query the system trust store at runtime on iOS/arm. That
rationale never applied to `darwin/arm64` (macOS Apple Silicon),
which can still call the Security framework APIs the same way as
`darwin/amd64`. The static blob is also a decade out of date.
Drop the static-blob approach for arm64 entirely. Broaden the build
tags on `root_cgo_darwin.go` and the `nilref_*_darwin.go` files so
they cover `darwin && !ios` instead of `darwin && !arm && !arm64
&& !ios`, and delete `root_darwin_armx.go`. The `root_darwin_test.go`
arch skip is now also unnecessary; remove it. (iOS is still excluded;
nobody has been building cfssl for iOS in years and `SecKeychainItem
Export` remains restricted there.)
After this change, `darwin/arm64` uses the same runtime-query path
as `darwin/amd64`:
GOOS=darwin GOARCH=arm64 CGO_ENABLED=1 go build ./transport/...
GOOS=darwin GOARCH=arm64 CGO_ENABLED=1 go test ./transport/roots/system/
# TestSystemRoots now runs (was previously skipped) and passes.
Verified `SecKeychainItemExport` still functions on macOS 14 arm64
despite its 10.7-era deprecation warning.
Fixes cloudflare#1235.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
After this fix, cfssl will compile on Apple Silicon using the 'transport/roots/system/root_cgo_darwin.go' path. The 'armx' path seems to never have been functional. The rest of this description was generated w/ AI assistance. It's a bit wordy, but the context seems useful so I'm leaving it.
transport/roots/system/root_darwin_armx.godefined a voidinitSystemRoots()that referenced identifiers (systemRoots,NewCertPool,AppendCertsFromPEM) that don't exist in the package and that doesn't matchroot.go's caller signature. As a result, the package fails to compile ondarwin/arm64(Apple Silicon) with cgo enabled:Origin of the bug:
root_darwin_armx.gowas checked in on 2015-11-04 (0fd8a23) with this signature already wrong. The accompanying generatorroot_darwin_arm_gen.go(deleted in the same commit) emitted a header that would have produced the correctinitSystemRoots() []*x509.Certificate { ... return roots }shape, but the generated file committed alongside the generator's deletion was clearly produced by an earlier version of the tool and never re-run. The patternsystemRoots = NewCertPool()matches the internal API ofcrypto/x509circa Go ~1.5. The bug went unnoticed for ~5 years becausedarwin/arm64wasn't a common build target until Apple Silicon launched in late 2020; the first user report (#1235) is from August 2022.The file existed to embed a static blob of Apple-published iOS root certificates because, in 2015, the cgo path's
SecKeychainItemExportAPI was deprecated on iOS and there was no way to query the system trust store at runtime on iOS/arm. That rationale never applied todarwin/arm64(macOS Apple Silicon), which can still call the Security framework APIs the same way asdarwin/amd64. The static blob is also a decade out of date.Drop the static-blob approach for arm64 entirely. Broaden the build tags on
root_cgo_darwin.goand thenilref_*_darwin.gofiles so they coverdarwin && !iosinstead ofdarwin && !arm && !arm64 && !ios, and deleteroot_darwin_armx.go. Theroot_darwin_test.goarch skip is now also unnecessary; remove it. (iOS is still excluded; nobody has been building cfssl for iOS in years andSecKeychainItem Exportremains restricted there.)After this change,
darwin/arm64uses the same runtime-query path asdarwin/amd64:Verified
SecKeychainItemExportstill functions on macOS 14 arm64 despite its 10.7-era deprecation warning.Fixes #1235.