Running a SPIRE Agent on macOS by Building It Yourself
SPIRE 1.16.0 comes with release builds for Linux and Windows. There is no macOS download. For a design where a Mac may need a SPIFFE identity, that looked like a dead end until we tried the obvious thing: SPIRE is written in Go, so build it. It works. Here's the build, what makes it work on macOS, and a local end-to-end test that issues a real certificate. Build the agent You need Go and the…
Building and running a SPIRE agent on macOS requires compiling the agent from source, as there are no pre-built binaries available for the platform. The process involves installing Go and retrieving the SPIRE source from a specific release tag. After setting the appropriate environment variable to disable cgo and building the agent, it is large in size due to the inclusion of all plugins.
The agent's functionality relies on the Workload API, which allows it to determine which process is requesting an identity. On macOS, the agent uses kqueue to monitor the caller's PID and detect when processes exit. This prevents the reuse of PIDs to steal identities. The workload attestor on macOS uses various selectors, including user ID, group ID, and a binary-specific SHA256 hash, to tie an identity to a specific executable.
To validate the agent's functionality, a local end-to-end test was conducted, involving the creation of a throwaway SPIRE server and the agent on the same Mac. The server uses SQLite, which requires cgo, while the agent does not. The test involved starting the server, generating a join token, and creating an identity for the user running the test.
The resulting certificate issued by the agent carries the SPIFFE ID as a URI SAN and is valid for one hour. The agent automatically rotates the certificate before it expires. In practice, running the agent as a service using launchd and establishing a consistent socket path for clients is recommended. While the test demonstrates the agent's ability to run on macOS, it should be noted that a production setup would involve additional considerations such as node attestation, join token management, and potential integration with Secure Enclave attestation.
Rewritten by urgent.news; may contain errors — check the original.
Source: dev.to