|
49 | 49 | // log.Fatal(err)
|
50 | 50 | // }
|
51 | 51 | // clientCert = append(clientCert, certs)
|
| 52 | +// cipherSuites := []uint16{ |
| 53 | +// // These 10 are the normal Go 1.22+ defaults |
| 54 | +// tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, |
| 55 | +// tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, |
| 56 | +// tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, |
| 57 | +// tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, |
| 58 | +// tls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305, |
| 59 | +// tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305, |
| 60 | +// tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, |
| 61 | +// tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, |
| 62 | +// tls.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, |
| 63 | +// tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, |
| 64 | +// |
| 65 | +// // These 4 use RSA key exchange, no longer included by default in Go 1.22+ |
| 66 | +// // but often needed to connect to MySQL 5.7, MariaDB 10.1, or anything older |
| 67 | +// tls.TLS_RSA_WITH_AES_128_GCM_SHA256, |
| 68 | +// tls.TLS_RSA_WITH_AES_256_GCM_SHA384, |
| 69 | +// tls.TLS_RSA_WITH_AES_128_CBC_SHA, |
| 70 | +// tls.TLS_RSA_WITH_AES_256_CBC_SHA, |
| 71 | +// } |
52 | 72 | // mysql.RegisterTLSConfig("custom", &tls.Config{
|
53 | 73 | // RootCAs: rootCertPool,
|
54 | 74 | // Certificates: clientCert,
|
| 75 | +// |
| 76 | +// // Only include the following two lines when supporting older servers |
| 77 | +// CipherSuites: cipherSuites, // in Go 1.22+, allow TLS connection to MySQL 5.x or MariaDB 10.1 or older |
| 78 | +// MinVersion: tls.VersionTLS10, // in Go 1.18+, allow TLS connection to MySQL 5.6 or older |
55 | 79 | // })
|
56 | 80 | // db, err := sql.Open("mysql", "user@tcp(localhost:3306)/test?tls=custom")
|
57 | 81 | func RegisterTLSConfig(key string, config *tls.Config) error {
|
|
0 commit comments