Skip to content
This repository was archived by the owner on Jan 20, 2022. It is now read-only.

Add a check to renew certificates on startup if they expire in 60 days or less - #309

Merged
justinsb merged 1 commit into
kopeio:masterfrom
coderanger:renew-cert
Apr 26, 2020
Merged

justinsb merged 1 commit into
kopeio:masterfrom
coderanger:renew-cert

Conversation

@coderanger

Copy link
Copy Markdown
Contributor

Not a perfect fix, if you don't restart things every now and then, they could still expire. But it's at least closer and means if you do restart things, it will fix itself.

@coderanger coderanger changed the title Add a check to renew certificates on startup if they expire in 60 days of less Add a check to renew certificates on startup if they expire in 60 days or less Apr 23, 2020
@mitch000001

Copy link
Copy Markdown

@coderanger what's your opinion on putting these checks into etcd metrics somehow?

@coderanger

Copy link
Copy Markdown
Contributor Author

@mitch000001 We didn't have it set up against etcd but blackbox_exporter does report HTTPS cert expiration times so that might be easier.

@zetaab

zetaab commented Apr 24, 2020

Copy link
Copy Markdown
Contributor

@coderanger do you have example how to check these certs with blackbox_exporter? just like https normally or how?

Comment thread pkg/pki/certs.go

match := true

if match && time.Until(cert.NotAfter) <= RENEW_THRESHOLD {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I think I hadn't intended to persist these keys at all.

One option is just to use a in memory key store; but I do like what you have here. A twist on this could be to regenerate if the key was issued > 24 hours ago, which is similar to no persistence, but offers some consistency over the short term.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I'm trying to figure out if there's a reason why we do persist these keys, when we don't persist others)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it’s possible that all this logic should be removed and just regen the cert on every startup. My only worry was entropy depletion since remaking the key would spike that pretty hard during system startup. But just the cert shouldn’t be an issue I think?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point that this is a cheaper operation because it's only the cert, not the key.

I think this fix is the right one to do immediately; I might tweak the threshold, but I'd rather get this merged and then look at what happens e.g. if I take that threshold effectively to zero.

@justinsb

Copy link
Copy Markdown
Contributor

Thanks for fixing @coderanger ... I'm going to merge and experiment with even shorter expiration times!

@justinsb
justinsb merged commit f808215 into kopeio:master Apr 26, 2020
justinsb added a commit to justinsb/kops that referenced this pull request Apr 28, 2020
Contains the workaround for 1-year certificate expiry.

Full changes

* Release notes for 3.0.20200307 [kubernetes#303](kopeio/etcd-manager#303)
* Add support for etcd 3.3.17 [kubernetes#304](kopeio/etcd-manager#304)
* Adding client usage extension for server cert (kubernetes#305) [kubernetes#306](kopeio/etcd-manager#306)
* Add a check to renew certificates on startup if they expire in 60 days or less [kubernetes#309](kopeio/etcd-manager#309)
* Try github actions [kubernetes#310](kopeio/etcd-manager#310)
* Upgrade bazel to 2.2.0 [kubernetes#311](kopeio/etcd-manager#311)
* Update to go 1.13.10 [kubernetes#314](kopeio/etcd-manager#314)
* Bazel: update dependency [kubernetes#316](kopeio/etcd-manager#316)
* e2e tests should wait for cluster readiness [kubernetes#318](kopeio/etcd-manager#318)
* Remove old bazel versions from travis [kubernetes#317](kopeio/etcd-manager#317)
* Always renew certificates [kubernetes#313](kopeio/etcd-manager#313)
hakman pushed a commit to hakman/kops that referenced this pull request May 2, 2020
Contains the workaround for 1-year certificate expiry.

Full changes

* Release notes for 3.0.20200307 [kubernetes#303](kopeio/etcd-manager#303)
* Add support for etcd 3.3.17 [kubernetes#304](kopeio/etcd-manager#304)
* Adding client usage extension for server cert (kubernetes#305) [kubernetes#306](kopeio/etcd-manager#306)
* Add a check to renew certificates on startup if they expire in 60 days or less [kubernetes#309](kopeio/etcd-manager#309)
* Try github actions [kubernetes#310](kopeio/etcd-manager#310)
* Upgrade bazel to 2.2.0 [kubernetes#311](kopeio/etcd-manager#311)
* Update to go 1.13.10 [kubernetes#314](kopeio/etcd-manager#314)
* Bazel: update dependency [kubernetes#316](kopeio/etcd-manager#316)
* e2e tests should wait for cluster readiness [kubernetes#318](kopeio/etcd-manager#318)
* Remove old bazel versions from travis [kubernetes#317](kopeio/etcd-manager#317)
* Always renew certificates [kubernetes#313](kopeio/etcd-manager#313)
hakman pushed a commit to hakman/kops that referenced this pull request May 2, 2020
Contains the workaround for 1-year certificate expiry.

Full changes

* Release notes for 3.0.20200307 [kubernetes#303](kopeio/etcd-manager#303)
* Add support for etcd 3.3.17 [kubernetes#304](kopeio/etcd-manager#304)
* Adding client usage extension for server cert (kubernetes#305) [kubernetes#306](kopeio/etcd-manager#306)
* Add a check to renew certificates on startup if they expire in 60 days or less [kubernetes#309](kopeio/etcd-manager#309)
* Try github actions [kubernetes#310](kopeio/etcd-manager#310)
* Upgrade bazel to 2.2.0 [kubernetes#311](kopeio/etcd-manager#311)
* Update to go 1.13.10 [kubernetes#314](kopeio/etcd-manager#314)
* Bazel: update dependency [kubernetes#316](kopeio/etcd-manager#316)
* e2e tests should wait for cluster readiness [kubernetes#318](kopeio/etcd-manager#318)
* Remove old bazel versions from travis [kubernetes#317](kopeio/etcd-manager#317)
* Always renew certificates [kubernetes#313](kopeio/etcd-manager#313)
hakman pushed a commit to hakman/kops that referenced this pull request May 2, 2020
Contains the workaround for 1-year certificate expiry.

Full changes

* Release notes for 3.0.20200307 [kubernetes#303](kopeio/etcd-manager#303)
* Add support for etcd 3.3.17 [kubernetes#304](kopeio/etcd-manager#304)
* Adding client usage extension for server cert (kubernetes#305) [kubernetes#306](kopeio/etcd-manager#306)
* Add a check to renew certificates on startup if they expire in 60 days or less [kubernetes#309](kopeio/etcd-manager#309)
* Try github actions [kubernetes#310](kopeio/etcd-manager#310)
* Upgrade bazel to 2.2.0 [kubernetes#311](kopeio/etcd-manager#311)
* Update to go 1.13.10 [kubernetes#314](kopeio/etcd-manager#314)
* Bazel: update dependency [kubernetes#316](kopeio/etcd-manager#316)
* e2e tests should wait for cluster readiness [kubernetes#318](kopeio/etcd-manager#318)
* Remove old bazel versions from travis [kubernetes#317](kopeio/etcd-manager#317)
* Always renew certificates [kubernetes#313](kopeio/etcd-manager#313)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants