Knex: Can KnexJS support MySQL SSL?

Created on 11 Jan 2016  Â·  1Comment  Â·  Source: knex/knex

I am trying to login to a Mariadb using SSL, in Python you can do this:

sl = {‘cert’: ‘/etc/mysql-ssl/client-cert.pem’, ‘key’: ‘/etc/mysql-ssl/client-key.pem’}
conn = MySQLdb.connect(host=’127.0.0.1′, user=’ssluser’, passwd=’pass’, ssl=ssl)

Can KnexJS support SSL?

Most helpful comment

The connection property of your knex config is proxied through to the underlaying client module when creating the connection, so you could try to do something like this:

db = knex({
client: 'mysql',
connection: {
host: 'localhost',
 ssl  : {
    ca : fs.readFileSync(__dirname + '/mysql-ca.crt')
  }
}
})

See https://www.npmjs.com/package/mysql#ssl-options for more detailed info.

>All comments

The connection property of your knex config is proxied through to the underlaying client module when creating the connection, so you could try to do something like this:

db = knex({
client: 'mysql',
connection: {
host: 'localhost',
 ssl  : {
    ca : fs.readFileSync(__dirname + '/mysql-ca.crt')
  }
}
})

See https://www.npmjs.com/package/mysql#ssl-options for more detailed info.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nklhrstv picture nklhrstv  Â·  3Comments

mishitpatel picture mishitpatel  Â·  3Comments

zettam picture zettam  Â·  3Comments

tjwebb picture tjwebb  Â·  3Comments

fsebbah picture fsebbah  Â·  3Comments