-
Notifications
You must be signed in to change notification settings - Fork 14
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 user provided certificates #834
base: main
Are you sure you want to change the base?
Conversation
54d9e7b
to
f514e7f
Compare
We'll validate user provided certificates, checking fields such as: * Common Name * Organization * NotBefore, NotAfter * DNS Subject Alternative Name Also, we ensure that the certificates are signed by the specified CAs.
f514e7f
to
3d28d7c
Compare
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, only minor nits and a question
DNSSANs: []string{"kubernetes", "kubernetes.default", "kubernetes.default.svc", "kubernetes.default.svc.cluster", "kubernetes.default.svc.cluster.local"}, | ||
} | ||
if err := certCheck.ValidateKeypair(c.APIServerCert, c.APIServerKey); err != nil { | ||
return fmt.Errorf("kube-apiservert certificate validation failure: %w", err) |
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.
nit: typo
@@ -142,4 +190,101 @@ func TestControlPlaneCertificates(t *testing.T) { | |||
g.Expect(cert.DNSNames).To(ConsistOf(expectedDNSNames)) | |||
}) | |||
}) | |||
|
|||
t.Run("InvalidSan", func(t *testing.T) { |
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.
nit: InvalidSAN
according to go convention
} | ||
} | ||
for _, ip := range check.IPSANs { | ||
if err := cert.VerifyHostname("[" + ip + "]"); err != nil { |
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.
Is this IPv6-safe?
I guess ip
cannot be [<ipv6>]
so that we would have double brackets, right?
We'll validate user provided certificates, checking fields such as:
Also, we ensure that the certificates are signed by the specified CAs.