-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
security: parse certificates at load time and export expiration time. #16045
Conversation
a4b9f9c
to
2394727
Compare
b862c27
to
66c9104
Compare
Work towards #15027 We need access to the certificate fields for debugging/monitoring/etc... Parse the certificates at load time, saving the parsed version and persisting any errors (we're still less strict than the tls code). For now, just show the expiration time in the list command. eg: ``` $ ./cockroach cert list Certificate directory: ${HOME}/.cockroach-certs +-----------------------+------------------+-----------------+-----------+------------+-------+ | Usage | Certificate File | Key File | Notes | Expires | Error | +-----------------------+------------------+-----------------+-----------+------------+-------+ | Certificate Authority | ca.crt | | | 2027/05/27 | | | Node | node.crt | node.key | | 2027/05/27 | | | Client | client.root.crt | client.root.key | user=root | 2027/05/27 | | +-----------------------+------------------+-----------------+-----------+------------+-------+ ```
66c9104
to
4f30a7f
Compare
Second commit adds metrics for ca/node expiration times. |
4f30a7f
to
7b75404
Compare
7b75404
to
0c5c08d
Compare
Reviewed 3 of 3 files at r1, 3 of 3 files at r2. pkg/security/certificate_loader.go, line 371 at r1 (raw file):
Not important, but what does the "der" in pkg/security/certificate_manager.go, line 41 at r2 (raw file):
s/timemestamp/timestamp pkg/security/certificate_manager.go, line 248 at r2 (raw file):
Should we explicitly Ditto for the node cert metric. Comments from Reviewable |
0c5c08d
to
1225799
Compare
Review status: all files reviewed at latest revision, 3 unresolved discussions, all commit checks successful. pkg/security/certificate_loader.go, line 371 at r1 (raw file): Previously, a-robinson (Alex Robinson) wrote…
it's the encoding format for the certificate. not to be confused with PEM encoding which is more of an envelope. pkg/security/certificate_manager.go, line 41 at r2 (raw file): Previously, a-robinson (Alex Robinson) wrote…
Done. pkg/security/certificate_manager.go, line 248 at r2 (raw file): Previously, a-robinson (Alex Robinson) wrote…
True. It's currently not possible (I bail early from the caller if the cert goes from good to bad), but it doesn't hurt. Comments from Reviewable |
Reviewed 1 of 1 files at r3. Comments from Reviewable |
Review status: all files reviewed at latest revision, 4 unresolved discussions, all commit checks successful. pkg/security/certificate_loader.go, line 130 at r3 (raw file):
pkg/security/certificate_loader.go, line 136 at r3 (raw file):
Should this be the earliest Comments from Reviewable |
Review status: all files reviewed at latest revision, 4 unresolved discussions, all commit checks successful. pkg/security/certificate_loader.go, line 130 at r3 (raw file): Previously, petermattis (Peter Mattis) wrote…
Done. pkg/security/certificate_loader.go, line 136 at r3 (raw file): Previously, petermattis (Peter Mattis) wrote…
Only CA cert files should have more than one certificate (it's technically possible to have more than one in non-CA cert files, but it won't do anything). When your CA cert is about to expire (ideally months before), you should generate a new CA certificate and add it to the same file, using all CAs in your pool. This means that you may have one cert about to expire (or already expired) and another expiring in X years. Assuming the rest of your certificate rollout is done properly, your deadline is expiration date of the longest-lived CA. Comments from Reviewable |
5cc96ed
to
038880d
Compare
Review status: 4 of 6 files reviewed at latest revision, 4 unresolved discussions, some commit checks pending. pkg/security/certificate_loader.go, line 136 at r3 (raw file): Previously, mberhault (marc) wrote…
There is one caveat but it's on the node cert, not the CA cert: Comments from Reviewable |
The need to monitor certificate chains is alleviated a bit by #16055. However, someone not using the cockroach cli to generate certs could still have mismatched node/CA expirations. |
Reviewed 2 of 3 files at r1, 2 of 3 files at r2, 2 of 2 files at r4. Comments from Reviewable |
Work towards #15027
Parse certificates at load time. Any failures are persisted for clarity.
For now, only the expiration time is used (in
cockroach cert list
and metrics) but debug pages will make use of the parsed certificates.