-
Notifications
You must be signed in to change notification settings - Fork 1.2k
validate cert #74
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
validate cert #74
Conversation
cc: @anfernee |
// Recreate the cert if it's invalid. | ||
if !validCert(certs) { | ||
valid, err := validCert(certs, dnsName, 6*month) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe move 6*month
to a constant.
// e.g. | ||
// c, err := tls.X509KeyPair(cert, key) | ||
// err := c.Verify(options) | ||
func validCert(certs *generator.Artifacts, dnsName string, validTime time.Duration) (bool, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the return statements returns error as nil
. I think you can remove this argument from the return list. Then validCert
returns only a bool
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch
// e.g. | ||
// c, err := tls.X509KeyPair(cert, key) | ||
// err := c.Verify(options) | ||
func validCert(certs *generator.Artifacts, dnsName string, validTime time.Duration) (bool, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The linter is complaining about parameter validTime
not being changed :/
It is handy to have this parameter for testing purpose.
PTAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good, a minor comment.
@@ -39,6 +42,8 @@ const ( | |||
ServerCertName = "cert.pem" | |||
) | |||
|
|||
const sixMonths = 6 * 31 * 24 * time.Hour |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does it have to be pkg level const ? I see it only being used inside a fn.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry for the late response. I still don't see where the notification goes to.
LGTM overall. just a question about the 6mo const
ops := x509.VerifyOptions{ | ||
DNSName: dnsName, | ||
Roots: pool, | ||
CurrentTime: time.Now().Add(sixMonths), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why 6 months? also it's more like time.Now().AddDate(0, 1, 0)
doc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point!
Updated
PTAL |
/lgtm |
fixed infinite loop in watchControllerOf API
No description provided.