TSL certificates are kept on disk after service removal

Description

When you start monitoring a service that requires a TLS certificate to be able to connect to the database, PMM Client creates the following artifacts:

  • a directory per agent type in /usr/local/percona/pmm/tmp, where the certificates get persisted to the file system, ex: ../tmp/agent_type_mysqld_exporter/2d44b1ba-5131-4fbd-8dc0-aae0f23b043b with three certificates inside, including the private certificate

  • additional directories, which depend on the exporter type, for example: ../tmp/check-mysql-connection or ../tmp/get-mysql-info

Later, when the service is removed, some of the certificates are still kept on disk instead of being deleted.

We think this could be a problem from two perspectives:

  • unnecessary use of disk space

  • security (especially the private key)

 

Solution

Implement an additional step to the service removal routine where all the certificates and intermediary files related to the services being removed are deleted from the file system.

How to test

  • Set up a database with SSL certificates

  • Add the database a service to PMM monitoring by proving the paths to certificates as params

  • Find these certificates persisted in /usr/local/percona/pmm/tmp

  • Remove the service

  • Confirm that the certificates have been removed

How to document

This PR fixes a problem where TLS certificates and some other auxiliary files were kept in the agent’s “tmp” directory after service removal or after pmm-agent was stopped. They get removed now after service removal, which should improve the overall PMM Agent security.

Smart Checklist

hide

Activity

Show:
Done

Details

Assignee

Reporter

Priority

Components

Needs QA

Needs Doc

Planned Version/s

Fix versions

Story Points

Sprint

Affects versions

Smart Checklist Progress

Start date

Due date

Smart Checklist

Created February 12, 2025 at 4:24 PM
Updated yesterday
Resolved yesterday