Skip to content

Conversation

@lukebakken
Copy link
Collaborator

RabbitMQ currently accepts invalid TLS certificate files at startup without validation, only failing silently when clients attempt to connect. This occurs because Erlang's TLS implementation lazily loads certificates on first connection rather than at configuration time. Users may not discover misconfigured certificates until production traffic fails.

This change adds a pem_file validator to the cuttlefish schema that reads certificate files and validates they contain valid PEM data using public_key:pem_decode/1. The validator rejects empty files and files without valid PEM entries, causing RabbitMQ to fail at startup with a clear error message identifying the invalid file.

The validator applies to all TLS certificate file mappings across 6 schema files: cacertfile, certfile, and keyfile for main listeners, definitions import, syslog, HTTP auth backend, LDAP auth backend, and peer discovery (Consul, etcd, Kubernetes). DH parameter files continue using the existing file_accessible validator since they are not PEM-encoded certificates.

Fixes #15065

@lukebakken lukebakken self-assigned this Dec 4, 2025
@lukebakken lukebakken marked this pull request as draft December 4, 2025 22:42
@michaelklishin
Copy link
Collaborator

Can these fixture files be renamed to reflect that they are "server certificates" in the EKUs sense?

Looking at the direction the industry is going, I would not be surprised if we were to introduce a key usage validation on top, and in that case knowing which fixture file has which EKUs just from the name would help.

And well, tls-gen already names the files it produces that way, so we can just copy a few valid certificates and keys with a 10 year expiration.

@lukebakken lukebakken force-pushed the rabbitmq-server-15065 branch from b63f717 to 9de77c9 Compare December 5, 2025 01:58
@lukebakken lukebakken marked this pull request as ready for review December 5, 2025 15:56
@lukebakken lukebakken requested a review from Zerpet December 5, 2025 15:56
@lukebakken
Copy link
Collaborator Author

@michaelklishin @Zerpet I'm going to do one last review for PEM settings that are "sneaky" like oauth2's signing_keys

@lukebakken lukebakken marked this pull request as draft December 5, 2025 17:16
@lukebakken lukebakken force-pushed the rabbitmq-server-15065 branch 4 times, most recently from cdfbc47 to ef0bbac Compare December 5, 2025 19:37
@lukebakken
Copy link
Collaborator Author

FYI there is a deps/rabbitmq_prometheus/test/config_schema_SUITE_data/schema directory that I deleted since it seems like those were added by mistake a while ago.

@lukebakken lukebakken force-pushed the rabbitmq-server-15065 branch from ef0bbac to 2fdb991 Compare December 5, 2025 19:51
RabbitMQ currently accepts invalid TLS certificate files at startup
without validation, only failing silently when clients attempt to
connect. This occurs because Erlang's TLS implementation lazily loads
certificates on first connection rather than at configuration time.
Users may not discover misconfigured certificates until production
traffic fails.

This change adds a `pem_file` validator to the cuttlefish schema that
reads certificate files and validates they contain valid PEM data using
`public_key:pem_decode/1`. The validator rejects empty files and files
without valid PEM entries, causing RabbitMQ to fail at startup with a
clear error message identifying the invalid file.

The validator applies to all TLS certificate file mappings across 6
schema files: `cacertfile`, `certfile`, and `keyfile` for main
listeners, definitions import, syslog, HTTP auth backend, LDAP auth
backend, and peer discovery (Consul, etcd, Kubernetes). DH parameter
files continue using the existing `file_accessible` validator since they
are not PEM-encoded certificates.

Valid X509 certs are now required for schema tests.

Fixes rabbitmq#15065
@lukebakken lukebakken force-pushed the rabbitmq-server-15065 branch from 2fdb991 to bcff79f Compare December 5, 2025 21:44
@lukebakken lukebakken marked this pull request as ready for review December 5, 2025 23:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants