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

npow picture npow  Â·  3Comments

PaulOlteanu picture PaulOlteanu  Â·  3Comments

sandrocsimas picture sandrocsimas  Â·  3Comments

legomind picture legomind  Â·  3Comments

koskimas picture koskimas  Â·  3Comments