-
Notifications
You must be signed in to change notification settings - Fork 18k
crypto/x509: Other Names in x509 Certificate SAN causing certificate verification failure #35467
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
Comments
CC @agl @FiloSottile |
I think you would want to set Seeing the default verification might be useful to crib from — the thing you need to avoid is configuring a (If @FiloSottile suggests something different, listen to him.) |
Change https://golang.org/cl/193620 mentions this issue: |
Setting InsecureSkipVerify and VerifyPeerCertificate is the recommended way to customize and override certificate validation. However, there is boilerplate involved and it usually requires first reimplementing the default validation strategy to then customize it. Provide an example that does the same thing as the default as a starting point. Examples of where we directed users to do something similar are in issues #35467, #31791, #28754, #21971, and #24151. Fixes #31792 Change-Id: Id033e9fa3cac9dff1f7be05c72dfb34b4f973fd4 Reviewed-on: https://go-review.googlesource.com/c/go/+/193620 Reviewed-by: Adam Langley <[email protected]>
Indeed, a custom verifier is your best bet. I just submitted an example to the docs that should help you. https://tip.golang.org/pkg/crypto/tls/#example_Config_verifyPeerCertificate (The logic ignoring CN is more complex than just letting SAN take priority per RFC 6125, because it interacts with Name Constraints due to our VerifyHostname API only having access to the leaf. #24151) |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Attempted to bind to an LDAP Server over 636 w/ TLS
What did you expect to see?
Successful binding
What did you see instead?
LDAP Result Code 200 "Network Error": x509: certificate is not valid for any names, but wanted to match
By debugging I determine that the source of this error is that my LDAP host is serving a certificate without a
DNSName
in the SAN but with twoOther Name
elements. These two elements are related to OID 1.3.6.1.5.2.2 (Kerberos/Microsoft NT Principal Name). In this scenario, hasSANExtension() ==true
which makes commonNameAsHostName() ==false
. Because of this, the x509's verify function expects to find the hostname in the SAN but cannot, and throws an error. Interestingly, the hostname is parsable from the Microsoft NT Principal Name.When I look at RFC 6125:
My question is: is there a way to call my own custom middleware or function for hostname verification in support of the above-mentioned "application-specific identifier types" like my Kerberos application? Speaking to the issuer of my certificate, it sounds like I am unlikely to get them to modify the certificate anytime soon.
Any guidance is appreciated. Thank you!
The text was updated successfully, but these errors were encountered: