File tree 2 files changed +21
-16
lines changed
2 files changed +21
-16
lines changed Original file line number Diff line number Diff line change 1
1
package mysql
2
2
3
3
import (
4
+ "crypto/tls"
4
5
"database/sql"
5
6
"fmt"
6
7
"io"
@@ -840,7 +841,7 @@ func TestStrict(t *testing.T) {
840
841
}
841
842
842
843
func TestTLS (t * testing.T ) {
843
- runTests ( t , dsn + "&tls=skip-verify" , func (dbt * DBTest ) {
844
+ tlsTest := func (dbt * DBTest ) {
844
845
if err := dbt .db .Ping (); err != nil {
845
846
if err == errNoTLS {
846
847
dbt .Skip ("Server does not support TLS" )
@@ -861,7 +862,15 @@ func TestTLS(t *testing.T) {
861
862
dbt .Fatal ("No Cipher" )
862
863
}
863
864
}
865
+ }
866
+
867
+ runTests (t , dsn + "&tls=skip-verify" , tlsTest )
868
+
869
+ // Verify that registering / using a custom cfg works
870
+ RegisterTLSConfig ("custom-skip-verify" , & tls.Config {
871
+ InsecureSkipVerify : true ,
864
872
})
873
+ runTests (t , dsn + "&tls=custom-skip-verify" , tlsTest )
865
874
}
866
875
867
876
// Special cases
Original file line number Diff line number Diff line change @@ -83,24 +83,20 @@ var tlsConfigMap map[string]*tls.Config
83
83
// Use the key as a value in the DSN where tls=value.
84
84
//
85
85
// rootCertPool := x509.NewCertPool()
86
- // {
87
- // pem, err := ioutil.ReadFile("/path/ca-cert.pem")
88
- // if err != nil {
89
- // log.Fatal(err)
90
- // }
91
- // if ok := rootCertPool.AppendCertsFromPEM(pem); !ok {
92
- // log.Fatal("Failed to append PEM.")
93
- // }
86
+ // pem, err := ioutil.ReadFile("/path/ca-cert.pem")
87
+ // if err != nil {
88
+ // log.Fatal(err)
89
+ // }
90
+ // if ok := rootCertPool.AppendCertsFromPEM(pem); !ok {
91
+ // log.Fatal("Failed to append PEM.")
94
92
// }
95
93
// clientCert := make([]tls.Certificate, 0, 1)
96
- // {
97
- // certs, err := tls.LoadX509KeyPair("/path/client-cert.pem", "/path/client-key.pem")
98
- // if err != nil {
99
- // log.Fatal(err)
100
- // }
101
- // clientCert = append(clientCert, certs)
94
+ // certs, err := tls.LoadX509KeyPair("/path/client-cert.pem", "/path/client-key.pem")
95
+ // if err != nil {
96
+ // log.Fatal(err)
102
97
// }
103
- // mysql.RegisterTLSConfig("custom", tls.Config{
98
+ // clientCert = append(clientCert, certs)
99
+ // mysql.RegisterTLSConfig("custom", &tls.Config{
104
100
// RootCAs: rootCertPool,
105
101
// Certificates: clientCert,
106
102
// })
You can’t perform that action at this time.
0 commit comments