Validate cert store before running the agent
If the --server-url
flag or the STORK_AGENT_SERVER_URL
environment variable is not used, the agent certificates and tokens are not validated.
It causes the Stork agent to run without some certs or with invalid ones. The agent is running, but it isn't operational. It throws a lot of weird errors on every connection.
We must always verify the certs on startup, prevent running the agent if something is wrong, and print the descriptive log message to hint users they must manually re-register the agent.
time="2024-03-29 07:32:20" level="error" msg="Could not setup TLS key pair" file=" agent.go:98 " error="could not read the private key: could not read the file: /var/lib/stork-agent/certs/key.pem: open /var/lib/stork-agent/certs/key.pem: no such file or directory"