Skip to content

Commit b18f20a

Browse files
committed
Revise documentation for RegisterTLSConfig
1 parent 4974720 commit b18f20a

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

README.md

+1-10
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ A MySQL-Driver for Go's [database/sql](http://golang.org/pkg/database/sql) packa
1919
* [Address](#address)
2020
* [Parameters](#parameters)
2121
* [Examples](#examples)
22-
* [TLS support](#tls-support)
2322
* [LOAD DATA LOCAL INFILE support](#load-data-local-infile-support)
2423
* [time.Time support](#timetime-support)
2524
* [Unicode support](#unicode-support)
@@ -114,7 +113,7 @@ Possible Parameters are:
114113
* `parseTime`: `parseTime=true` changes the output type of `DATE` and `DATETIME` values to `time.Time` instead of `[]byte` / `string`
115114
* `strict`: Enable strict mode. MySQL warnings are treated as errors.
116115
* `timeout`: **Driver** side connection timeout. The value must be a string of decimal numbers, each with optional fraction and a unit suffix ( *"ms"*, *"s"*, *"m"*, *"h"* ), such as *"30s"*, *"0.5m"* or *"1m30s"*. To set a server side timeout, use the parameter [`wait_timeout`](http://dev.mysql.com/doc/refman/5.6/en/server-system-variables.html#sysvar_wait_timeout).
117-
* `tls`: `true` enables TLS / SSL encrypted connection to the server. For other values see [TLS support](#tls-support).
116+
* `tls`: `true` enables TLS / SSL encrypted connection to the server. Use `skip-verify` if you want to use a self-signed or invalid certificate (server side). Use a custom value registered with [`mysql.RegisterTLSConfig`](http://godoc.org/github.com/go-sql-driver/mysql#RegisterTLSConfig).
118117

119118
All other parameters are interpreted as system variables:
120119
* `autocommit`: *"SET autocommit=`value`"*
@@ -144,14 +143,6 @@ No Database preselected:
144143
user:password@/
145144
```
146145

147-
### TLS support
148-
For TLS support set the `tls` parameter to one of the following values:
149-
150-
* `true`: Server certificate is signed by a trusted authority.
151-
* `skip-verify`: Server certificate is self-signed with no root authority.
152-
* `custom`: Server certifiate is signed by a self-managed authority, and/or a client certificate is used. `custom` can be any value that coorisponds to a custom `tls.Config` registered with [`mysql.RegisterTLSConfig`](http://godoc.org/github.com/go-sql-driver/mysql#RegisterTLSConfig).
153-
154-
155146
### `LOAD DATA LOCAL INFILE` support
156147
For this feature you need direct access to the package. Therefore you must change the import path (no `_`):
157148
```go

utils.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ var tlsConfigMap map[string]*tls.Config
8888
// if err != nil {
8989
// log.Fatal(err)
9090
// }
91-
// if ok := rootCAs.AppendCertsFromPEM(pem); !ok {
91+
// if ok := rootCertPool.AppendCertsFromPEM(pem); !ok {
9292
// log.Fatal("Failed to append PEM.")
9393
// }
9494
// }
@@ -98,7 +98,7 @@ var tlsConfigMap map[string]*tls.Config
9898
// if err != nil {
9999
// log.Fatal(err)
100100
// }
101-
// clientCert = append(clientCerts, certs)
101+
// clientCert = append(clientCert, certs)
102102
// }
103103
// mysql.RegisterTLSConfig("custom", tls.Config{
104104
// RootCAs: rootCertPool,
@@ -196,6 +196,7 @@ func parseDSN(dsn string) (cfg *config, err error) {
196196
cfg.tls = &tls.Config{}
197197
} else if strings.ToLower(value) == "skip-verify" {
198198
cfg.tls = &tls.Config{InsecureSkipVerify: true}
199+
// TODO: Check for Boolean false
199200
} else if tlsConfig, ok := tlsConfigMap[value]; ok {
200201
cfg.tls = tlsConfig
201202
}

0 commit comments

Comments
 (0)