Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connection error in AWS RDS SSL in NodeJS

I am trying to connect to RDS through Lambda NodeJS 12.x with SSL. However I am receiving these errors:

  Error: 4506652096:error:1425F102:SSL routines:ssl_choose_client_version:unsupported protocol:
  library: 'SSL routines',
  function: 'ssl_choose_client_version',
  reason: 'unsupported protocol',
  code: 'HANDSHAKE_SSL_ERROR' 

I am connecting like this:

const pool  = mysql.createPool({
  connectionLimit     : 10,
  host                : 'db.cqgcxllqwqnk.eu-central-1.rds.amazonaws.com',
  ssl                 : {
    ca                : fs.readFileSync(__dirname + '/rds-ca-2019-root.pem')
  },
  user                : ‘xxxxx’,
  password            : ‘xxxxxx’,
  database            : ‘xxxxxx’,
  multipleStatements  : true
});

When I connect with the certificate through MySql Workbench everything works just fine.

Any idea on how to solve this?

Thanks a lot!

like image 409
Kasper Sommer Avatar asked Nov 23 '25 04:11

Kasper Sommer


1 Answers

The problem was related to Mysql version and TLS version. This matrix shows that for MySQL 5.6 only TLS 1.0 is supported. Node.js 12 by default uses TLS 1.2.

https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_MySQL.html#MySQL.Concepts.SSLSupport

like image 76
Kasper Sommer Avatar answered Nov 25 '25 19:11

Kasper Sommer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!