@@ -35,16 +35,25 @@ const COLLATE_UTF8MB4_UNICODE_CI: u8 = 224;
35
35
/// rather than as program arguments.
36
36
///
37
37
/// The same options for `--ssl-mode` are supported as the `ssl-mode` query parameter:
38
- /// https://dev.mysql.com/doc/refman/8.0/en/connection-options.html#option_general_ssl-mode
38
+ /// <https://dev.mysql.com/doc/refman/8.0/en/connection-options.html#option_general_ssl-mode>
39
+ ///
40
+ /// ```text
41
+ /// mysql://<user>[:<password>]@<host>[:<port>]/<database>[?ssl-mode=<ssl-mode>[&ssl-ca=<path>]]
42
+ /// ```
43
+ /// where
44
+ /// ```text
45
+ /// ssl-mode = DISABLED | PREFERRED | REQUIRED | VERIFY_CA | VERIFY_IDENTITY
46
+ /// path = percent (URL) encoded path on the local machine
47
+ /// ```
39
48
///
40
49
/// If the `tls` feature is not enabled, `ssl-mode=DISABLED` and `ssl-mode=PREFERRED` are no-ops and
41
50
/// `ssl-mode=REQUIRED`, `ssl-mode=VERIFY_CA` and `ssl-mode=VERIFY_IDENTITY` are forbidden
42
51
/// (attempting to connect with these will return an error).
43
52
///
44
53
/// If the `tls` feature is enabled, an upgrade to TLS is attempted on every connection by default
45
54
/// (equivalent to `ssl-mode=PREFERRED`). If the server does not support TLS (because `--ssl=0` was
46
- /// passed or an invalid certificate or key was used,
47
- /// https://dev.mysql.com/doc/refman/8.0/en/using-encrypted-connections.html)
55
+ /// passed to the server or an invalid certificate or key was used:
56
+ /// < https://dev.mysql.com/doc/refman/8.0/en/using-encrypted-connections.html> )
48
57
/// then it falls back to an unsecured connection and logs a warning.
49
58
///
50
59
/// Add `ssl-mode=REQUIRED` to your connection string to emit an error if the TLS upgrade fails.
@@ -56,6 +65,17 @@ const COLLATE_UTF8MB4_UNICODE_CI: u8 = 224;
56
65
/// but is instead expected to be specified as a local path with the `ssl-ca` query parameter
57
66
/// (percent-encoded so the URL remains valid).
58
67
///
68
+ /// If you're running MySQL locally it might look something like this (for `VERIFY_CA`):
69
+ /// ```text
70
+ /// mysql://root:password@localhost/my_database?ssl-mode=VERIFY_CA&ssl-ca=%2Fvar%2Flib%2Fmysql%2Fca.pem
71
+ /// ```
72
+ ///
73
+ /// `%2F` is the percent-encoding for forward slash (`/`). In the example we give `/var/lib/mysql/ca.pem`
74
+ /// as the CA certificate path, which is generated by the MySQL server automatically if
75
+ /// no certificate is manually specified. Note that the path may vary based on the default `my.cnf`
76
+ /// packaged with MySQL for your Linux distribution. Also note that unlike MySQL, MariaDB does *not*
77
+ /// generate certificates automatically and they must always be passed in to enable TLS.
78
+ ///
59
79
/// If `ssl-ca` is not specified or the file cannot be read, then an error is returned.
60
80
/// `ssl-ca` implies `ssl-mode=VERIFY_CA` so you only actually need to specify the former
61
81
/// but you may prefer having both to be more explicit.
0 commit comments