Skip to content

Commit 62457c4

Browse files
committed
fix: SPIRE Agent crash on fresh clones (tls: illegal parameter)
Root cause: tpmPlugin was nil on fresh clones because tpm_plugin_cli.py path lookup only checked $HOME/AegisSovereignAI/..., which doesn't exist for repos cloned elsewhere. Without tpmPlugin, PreferPKCS1v15 TLS policy was not applied, causing Go to use RSA-PSS (default in TLS 1.3) which the TPM App Key cannot sign with, resulting in 'tls: illegal parameter'. Fixes: - test_agents.sh: export TPM_PLUGIN_CLI_PATH before SPIRE agent start - client.go: add binary-relative path detection + UDS-only fallback Verified: all integration tests pass on fresh clone (10.1.0.10).
1 parent 6f3f814 commit 62457c4

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

hybrid-cloud-poc/test_agents.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2721,6 +2721,16 @@ AGENT_CONFIG="${PROJECT_DIR}/python-app-demo/spire-agent.conf"
27212721
export TPM_PLUGIN_ENDPOINT="unix:///tmp/spire-data/tpm-plugin/tpm-plugin.sock"
27222722
fi
27232723

2724+
# Set TPM_PLUGIN_CLI_PATH so agent can find the TPM plugin CLI on any clone location
2725+
# Without this, PreferPKCS1v15 TLS policy won't be applied and the agent will crash
2726+
if [ -z "${TPM_PLUGIN_CLI_PATH:-}" ]; then
2727+
TPM_CLI_CANDIDATE="${SCRIPT_DIR}/tpm-plugin/tpm_plugin_cli.py"
2728+
if [ -f "${TPM_CLI_CANDIDATE}" ]; then
2729+
export TPM_PLUGIN_CLI_PATH="$(cd "$(dirname "${TPM_CLI_CANDIDATE}")" && pwd)/$(basename "${TPM_CLI_CANDIDATE}")"
2730+
echo " TPM_PLUGIN_CLI_PATH=${TPM_PLUGIN_CLI_PATH}"
2731+
fi
2732+
fi
2733+
27242734
# Verify TPM_PLUGIN_ENDPOINT is using UDS format (not TCP/IP)
27252735
if ! echo "${TPM_PLUGIN_ENDPOINT}" | grep -q "^unix://"; then
27262736
echo -e "${RED} ✗ ERROR: TPM_PLUGIN_ENDPOINT must use UDS format (unix://), got: ${TPM_PLUGIN_ENDPOINT}${NC}"

spire-fork/pkg/agent/client/client.go

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,21 @@ func newClient(c *Config) *client {
143143
if fflag.IsSet(fflag.FlagUnifiedIdentity) {
144144
pluginPath := os.Getenv("TPM_PLUGIN_CLI_PATH")
145145
if pluginPath == "" {
146+
// Look for the TPM plugin CLI in common locations
146147
possiblePaths := []string{
147148
"/tmp/spire-data/tpm-plugin/tpm_plugin_cli.py",
148149
filepath.Join(os.Getenv("HOME"), "AegisSovereignAI/hybrid-cloud-poc/tpm-plugin/tpm_plugin_cli.py"),
149150
}
151+
// Also check relative to SPIRE binary location (handles fresh clones)
152+
if exe, err := os.Executable(); err == nil {
153+
exeDir := filepath.Dir(exe)
154+
// binary is typically at <repo>/build/spire-binaries/spire-agent
155+
// tpm_plugin_cli.py is at <repo>/hybrid-cloud-poc/tpm-plugin/tpm_plugin_cli.py
156+
repoRoot := filepath.Join(exeDir, "..", "..")
157+
possiblePaths = append(possiblePaths,
158+
filepath.Join(repoRoot, "hybrid-cloud-poc/tpm-plugin/tpm_plugin_cli.py"),
159+
)
160+
}
150161
for _, path := range possiblePaths {
151162
if _, err := os.Stat(path); err == nil {
152163
pluginPath = path
@@ -155,12 +166,18 @@ func newClient(c *Config) *client {
155166
}
156167
}
157168

169+
tpmPluginEndpoint := os.Getenv("TPM_PLUGIN_ENDPOINT")
170+
if tpmPluginEndpoint == "" {
171+
tpmPluginEndpoint = "unix:///tmp/spire-data/tpm-plugin/tpm-plugin.sock"
172+
}
173+
158174
if pluginPath != "" {
159-
tpmPluginEndpoint := os.Getenv("TPM_PLUGIN_ENDPOINT")
160-
if tpmPluginEndpoint == "" {
161-
tpmPluginEndpoint = "unix:///tmp/spire-data/tpm-plugin/tpm-plugin.sock"
162-
}
163175
cl.tpmPlugin = tpmplugin.NewTPMPluginGateway(pluginPath, "", tpmPluginEndpoint, c.Log)
176+
} else {
177+
// Even without CLI, initialize with just UDS endpoint for mTLS signing support
178+
// This ensures PreferPKCS1v15 TLS policy is applied on fresh clones
179+
c.Log.Info("Unified-Identity: TPM plugin CLI not found, initializing gateway with UDS endpoint only")
180+
cl.tpmPlugin = tpmplugin.NewTPMPluginGateway("", "", tpmPluginEndpoint, c.Log)
164181
}
165182
}
166183

0 commit comments

Comments
 (0)