-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Support for Optional TLS connections #899
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
I don't think we should support such a special use case. You can try tls=true, and if it failed, retry tls=false. |
Issue: go-sql-driver#899 Add `optional` config value to the `tls` config variable on the DSN. This results in a TLS connection when the server advertises this by the flag send in the initial packet.
FYI, "PREFERRED" is used for official client. (And it's default for now) |
Yes this is what libmysqlclient (5.7+) has and how it maps to the go driver:
One of the reasons for making Note that MariaDB doesn't have an |
I don't like "optional". How about "preferred" or "auto"? |
Definitely not "auto" as there isn't anything automatic here. Let's go for "preferred" then. |
Issue: go-sql-driver#899 Add `preferred` config value to the `tls` config variable on the DSN. This results in a TLS connection when the server advertises this by the flag send in the initial packet.
Issue: #899 Add `preferred` config value to the `tls` config variable on the DSN. This results in a TLS connection when the server advertises this by the flag send in the initial packet.
I want to know if this option supports? |
I don't think it is. Best to use certificates with the right SubjectAlternativeName's to match your host. If you really can't do that then use |
Hello! Sorry to treat this issue as a help desk, but I'm wondering how one could use this library + the I have code that currently looks like below but am not sure if it does var rootCA = []byte(`-----BEGIN CERTIFICATE-----
...
`)
func init() {
caCertPool := x509.NewCertPool()
caCertPool.AppendCertsFromPEM(rootCA)
tlsConnConfig := &tls.Config{RootCAs: caCertPool, InsecureSkipVerify: true}
mysql.RegisterTLSConfig("custom-config", tlsConnConfig)
} I ask because the // InsecureSkipVerify controls whether a client verifies the server's
// certificate chain and host name. If InsecureSkipVerify is true, crypto/tls
// accepts any certificate presented by the server and any host name in that
// certificate. In this mode, TLS is susceptible to machine-in-the-middle
// attacks unless custom verification is used. This should be used only for
// testing or in combination with VerifyConnection or VerifyPeerCertificate.
InsecureSkipVerify [bool](https://pkg.go.dev/builtin#bool) |
Issue description
On a large set of machines where:
And a go program that needs to connect to all of the servers (e.g. a monitoring application)
The program has a list with hostname, username and password for each server.
If it connects with
tls=true
ortls=skip-verify
then this works for all servers except for those who don't support TLS.If it connects without setting
tls
or by settingtls=false
then it works for all servers except for those who run withrequire_secure_transport
.Example code
Output:
Configuration
Driver version (or git SHA):
6be42e0
Go version: run
go version
in your consolego version go1.11.2 linux/amd64
Server version: E.g. MySQL 5.6, MariaDB 10.0.20
MySQL 8.0.11, MySQL 5.7.24
Server OS: E.g. Debian 8.1 (Jessie), Windows 10
Fedora 29 (but target is CentOS 7)
Possible solutions
tls=optional
option which results in TLS when the server has the SSL flag set and in clear-text when the server doesn't have this flag set.tls=true
ortls=skip-verify
in the driver or application.ErrNoTLS
error in the application and re-connect withtls=false
in the application.iirc option 2 is what https://github.com/github/orchestrator does at the moment.
Note that option 2 causes most connections to be clear-text and option 3 causes most connections to use TLS.
The text was updated successfully, but these errors were encountered: