-
Notifications
You must be signed in to change notification settings - Fork 0
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
x509: certificate relies on legacy Common Name field, use SANs or temporarily enable Common Name matching with GODEBUG=x509ignoreCN=0 #6
Comments
I tested again just now using the |
https://golang.org/doc/go1.15#commonname
It's probably worth toggling this setting on for both binaries at application startup. The bigger question: Is a certificate valid if no Subject Alternative Name is present? |
https://support.dnsimple.com/articles/what-is-ssl-san/
Since certificates have a limited lifetime, I expect the Go developer's assumption is that only very old, likely expired certificates will be missing a SANs entry. |
|
|
I think this is what I'll end up doing. Not sure yet if by adding an additional flag (e.g., |
This is worth noting:
If I read that correctly, then the environment variable approach to disable the behavioral change would not make it into later Go versions. Ultimately the certs that we're working with (locally generated by campus CA) would need to be replaced with certificates containing SANs entries (at least the single entry reflecting the DNS name). |
Relevant bits from the stdlib ( // ignoreCN disables interpreting Common Name as a hostname. See issue 24151.
var ignoreCN = !strings.Contains(os.Getenv("GODEBUG"), "x509ignoreCN=0")
// ...
const (
// ...
// NameConstraintsWithoutSANs results when a leaf certificate doesn't
// contain a Subject Alternative Name extension, but a CA certificate
// contains name constraints, and the Common Name can be interpreted as
// a hostname.
//
// This error is only returned when legacy Common Name matching is enabled
// by setting the GODEBUG environment variable to "x509ignoreCN=1". This
// setting might be removed in the future.
NameConstraintsWithoutSANs
// ...
)
// ...
// VerifyHostname returns nil if c is a valid certificate for the named host.
// Otherwise it returns an error describing the mismatch.
//
// IP addresses can be optionally enclosed in square brackets and are checked
// against the IPAddresses field. Other names are checked case insensitively
// against the DNSNames field. If the names are valid hostnames, the certificate
// fields can have a wildcard as the left-most label.
//
// The legacy Common Name field is ignored unless it's a valid hostname, the
// certificate doesn't have any Subject Alternative Names, and the GODEBUG
// environment variable is set to "x509ignoreCN=0". Support for Common Name is
// deprecated will be entirely removed in the future.
func (c *Certificate) VerifyHostname(h string) error {
// ...
} |
Probably worth evaluating our fleet to determine just how many of the certs failing this check we're actually dealing with. If just one, then we can likely consider that a bug with the certificate and work towards getting it replaced. |
Also relevant:
and: check-cert/cmd/check_cert/main.go Lines 206 to 214 in 6d84f77
|
Basically it's worth reconsidering support for ignoring SANs entries as part of resolving this. The two items would almost need to be considered together since they're related to the same overall issue. |
While we are using the support for skipping SANs checks (on our Nagios system) for systems that didn't have them at all, we were also using the The current version of this tool assumes that if you list any SANs entries, then you want exactly those SANs entries to be present on the certificate. More or less than specified is considered an error condition. All of that said, keeping the We're replacing local certs without SANs entries, so I suspect we'll be fine with the Go 1.15 default behavior and going forward should be fine with Go 1.16 changes. Once the first beta release of 1.16 drops we can test further. |
This is what we ended up doing.
Still the mindset here. |
From doc comments in the current codebase: check-cert/internal/certs/validation-hostname.go Lines 167 to 171 in aa19a9c
Not sure what else to do here. Perhaps sufficient support is present to consider this worked around/resolved for now:
|
While testing a preview build of the
check_cert
binary, the above error message was thrown when our Nagios instance used the Go 1.15-generated binary against a system without any SANs entries, but with theCommonName
field set.x509: certificate relies on legacy Common Name field, use SANs or temporarily enable Common Name matching with GODEBUG=x509ignoreCN=0
This problem was not surfaced when performing initial testing with the go1.15beta1 release as noted on #10.
The text was updated successfully, but these errors were encountered: