quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.77k stars 2.68k forks source link

Monitoring of TLS certificate validity via metric and health check #43190

Open ahus1 opened 1 month ago

ahus1 commented 1 month ago

Description

A TLS certificate for the HTTPS port needs to be renewed regularly. It would be good to be able to monitor this in Quarkus. This would spot problems when those are not rotated for some reason (either automation failed, or the manual process was forgotten, or certificate reloading didn't work as expected).

Implementation ideas

quarkus-bot[bot] commented 1 month ago

/cc @jmartisk (health), @xstefank (health)

xstefank commented 1 month ago

@cescoffier since you were doing some tls lately. We have an api to register health checks, it's just a matter of providing correct info.

cescoffier commented 1 month ago

That should be easy to implement except (you saw it coming right?) in one case: SNI.

When you use SNI, you provide multiple certificates. Do we want to check that all of them are valid (maybe some will be invalid but never requested because no one is using the associated hostname). For metrics we can use tags to identify the hostnames, for else I 'm not too sure.

Note that there is already an expiration check at startup, we can reuse the same code.

xstefank commented 1 month ago

If you point me to it, I can give it a shot.

cescoffier commented 1 month ago

https://github.com/quarkusio/quarkus/blob/main/extensions/tls-registry/runtime/src/main/java/io/quarkus/tls/runtime/CertificateRecorder.java#L105 is the method orchestrating the validation.