Skip to content

Conversation

@brandond
Copy link
Member

@brandond brandond commented Nov 18, 2021

This change fixes an issue with how server.ListenAndServe loads certificates. It sets up a memory -> kubernetes -> memory Secret storage stack, which combined with lazy (on-demand) loading of certificate data, caused the certificate to not be properly renewed when it expired.

It also resolves a regression from #38 - while IPv6 addresses are no longer rejected by the CN regex, they cannot actually be stored in the CN annotation, as semicolons are not allowed in annotation keys. This also fixes handling of hostnames that are more than 41 characters long.

@brandond brandond force-pushed the expire_debug branch 2 times, most recently from 6c57f83 to ba42cc3 Compare November 18, 2021 01:49
Copy link
Contributor

@nickgerace nickgerace left a comment

Choose a reason for hiding this comment

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

Thank you! The design lines up with what we discussed, so this LGTM.

}

if !factory.IsStatic(secret) && !factory.NeedsUpdate(l.maxSANs, secret, cn...) {
if factory.IsStatic(secret) || !factory.NeedsUpdate(l.maxSANs, secret, cn...) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch

Comment on lines +421 to +423
if err := l.updateCert(h); err != nil {
logrus.Errorf("failed to update cert with HTTP request Host header: %v", err)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Another good catch

Comment on lines +104 to +106
if err != nil && !errors.IsAlreadyExists(err) {
logrus.Warnf("Failed to create Kubernetes secret: %v", err)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add retry logic here or will the warning log suffice? I'm led the believe that a non-"IsNotFound" error will likely reappear upon retry, so I'm good with this "as-is", but thought I'd ask if you considered it.

Copy link
Member Author

Choose a reason for hiding this comment

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

The Kubernetes Secret also gets watched in the background, and the sync from the watch plus the write-back of any local updates to the secret will ensure that it is eventually consistent.

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