jeremydaly / serverless-mysql

A module for managing MySQL connections at SERVERLESS scale
MIT License
1.21k stars 83 forks source link

does this work with connecting to database over SSL #134

Closed mksuni closed 1 year ago

mksuni commented 2 years ago

I have a mysql database that requires connections over SSL . I didnt see options mentioned in the readme for connecting with SSL. Does the module support connections over SSL

sromic commented 1 year ago

@mksuni there is an option to set SSL within a connection config object. E.g.

  const mysqlInstance = mysql({
    config: {
      host: '127.0.0.1',
      port: 3306,
      user: 'root',
      password: 'passw0rd',
      database: 'test',
      ssl: {
        ca: fs.readFileSync(__dirname + '/certs/ca.pem'),
        key: fs.readFileSync(__dirname + '/certs/client-key.pem'),
        cert: fs.readFileSync(__dirname + '/certs/client-cert.pem'),
      },
    },
    library: require('mysql2'),
  });