Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/base/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@
constructor(opts) {
super();
this.config = opts.config;

if (typeof this.config.ssl === 'boolean' ) {

Check failure on line 41 in lib/base/connection.js

View workflow job for this annotation

GitHub Actions / lint-js

Delete `·`
this.config.ssl = this.config.ssl === true ? {} : undefined;
}

// TODO: fill defaults
// if no params, connect to /var/lib/mysql/mysql.sock ( /tmp/mysql.sock on OSX )
// if host is given, connect to host:3306
Expand Down
2 changes: 1 addition & 1 deletion typings/mysql/lib/Connection.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ export interface ConnectionOptions {
/**
* object with ssl parameters or a string containing name of ssl profile
*/
ssl?: string | SslOptions;
ssl?: string | boolean | SslOptions;

/**
* Return each row as an array, not as an object.
Expand Down
4 changes: 2 additions & 2 deletions website/docs/documentation/ssl.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ See full list of [SslOptions](https://github.com/sidorares/node-mysql2/blob/mast

## SSL Options

To enable SSL without manually providing certificates and assuming they are already trusted by the host machine, you can specify an empty object, for example:
To enable SSL without manually providing certificates and assuming they are already trusted by the host machine, you can specify `ssl: true` or `ssl: {}`, for example:

```ts
const connection = await mysql.createConnection({
host: 'localhost',
ssl: {},
ssl: true,
});
```

Expand Down
2 changes: 1 addition & 1 deletion website/docs/examples/connections/create-connection.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ const mysql = require('mysql2');

const connection = mysql.createConnection({
// ...
ssl: {},
ssl: true,
});

connection.addListener('error', (err) => {
Expand Down
Loading