Skip to content
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

Add support for wildcard SANs #84

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

xdqi
Copy link

@xdqi xdqi commented Nov 18, 2023

@brandond

This patch should fix k3s-io/k3s#7821

Note: The original way of checking the validity of SAN[1] is not consistent with x509 logic of Go's standard library. So I adapted it.

[1]: Go never use CN field of a X509 certificate to validate, it use SAN only.

https://github.com/golang/go/blob/631a6c2abfb2cf7a877ea80f98c504fc4e0077be/src/crypto/x509/verify.go#L109

@@ -244,7 +239,7 @@ func populateCN(secret *v1.Secret, cn ...string) *v1.Secret {
secret.Annotations = map[string]string{}
}
for _, cn := range cn {
if cnRegexp.MatchString(cn) {
if validHostnamePattern(cn) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure this is correct, as populateCN is also called to add CNs extracted from TLS handshakes and HTTP host headers. Since validHostnamePattern calls validHostname(host, true), I believe this would allow unauthenticated callers to make dynamiclistener add wildcard SANs, if they spoof the correct value. I think wildcards should only be added if requested by the administrator.

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.

wildcard domain support with --tls-san
2 participants