Skip to content

Commit f7a5c01

Browse files
committed
docs: expand ssl option section
closes #481
1 parent b56ee1f commit f7a5c01

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

Readme.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,7 @@ issue [#501](https://github.com/felixge/node-mysql/issues/501). (Default: `'fals
167167
with this, it exposes you to SQL injection attacks. (Default: `false`)
168168
* `flags`: List of connection flags to use other than the default ones. It is
169169
also possible to blacklist default ones. For more information, check [Connection Flags](#connection-flags).
170-
* `ssl`: object with ssl parameters ( same format as [crypto.createCredentials](http://nodejs.org/api/crypto.html#crypto_crypto_createcredentials_details) argument )
171-
or a string containing name of ssl profile. Currently only 'Amazon RDS' profile is bundled, containing CA from https://rds.amazonaws.com/doc/rds-ssl-ca-cert.pem
170+
* `ssl`: object with ssl parameters or a string containing name of ssl profile. See [SSL options](#ssl-options).
172171

173172

174173
In addition to passing these options as an object, you can also use a url
@@ -181,6 +180,28 @@ var connection = mysql.createConnection('mysql://user:pass@host/db?debug=true&ch
181180
Note: The query values are first attempted to be parsed as JSON, and if that
182181
fails assumed to be plaintext strings.
183182

183+
### SSL options
184+
185+
The `ssl` option in the connection options takes a string or an object. When given a string,
186+
it uses one of the predefined SSL profiles included. The following profiles are included:
187+
188+
* `"Amazon RDS"`: this profile is for connecting to an Amazon RDS server and contains the
189+
ca from https://rds.amazonaws.com/doc/rds-ssl-ca-cert.pem
190+
191+
When connecting to other servers, you will need to provide an object of options, in the
192+
same format as [crypto.createCredentials](http://nodejs.org/api/crypto.html#crypto_crypto_createcredentials_details).
193+
Please note the arguments expect a string of the certificate, not a file name to the
194+
certificate. Here is a simple example:
195+
196+
```js
197+
var connection = mysql.createConnection({
198+
host : 'localhost',
199+
ssl : {
200+
ca : fs.readFileSync(__dirname + '/mysql-ca.crt')
201+
}
202+
});
203+
```
204+
184205
## Terminating connections
185206

186207
There are two ways to end a connection. Terminating a connection gracefully is

0 commit comments

Comments
 (0)