Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

awsCaBundle not working as intended for import RDS cert #2869

Closed
mrajasekar-godaddy opened this issue Jul 21, 2024 · 5 comments
Closed

awsCaBundle not working as intended for import RDS cert #2869

mrajasekar-godaddy opened this issue Jul 21, 2024 · 5 comments

Comments

@mrajasekar-godaddy
Copy link

Hi Team,

Currently We are using promise-mysql which is a wrapper function of mysqljs

Currently when I use ssl: awsCaBundle to pull in the new cert in 2 possible ways

host: response.host, port: response.port, user: response.username, password: response.password, timezone: 'Z', ssl: { ca: awsCaBundle.ca, }, database: 'Hub' }

and

host: response.host, port: response.port, user: response.username, password: response.password, timezone: 'Z', ssl: awsCaBundle, database: 'Hub' }

Both doesn't work and it fails to connect to the Database.

Can someone help on this ? Is there is an issue with the imports ? or the way it's accessed.

CC: @wellwelwel For visibility

@mrajasekar-godaddy
Copy link
Author

mrajasekar-godaddy commented Jul 21, 2024

@wellwelwel Steps for reproduction

const mysql = require('promise-mysql');
const awsCaBundle = require('aws-ssl-profiles');

const connection = await mysql.createConnection{(
    host: response.host,
    port: response.port,
    user: response.username,
    password: response.password,
    timezone: 'Z',
    ssl: await awsCaBundle
})

If you use this way to connect to an RDS instance, it won't connect. Please let me know if you any additional details

@wellwelwel
Copy link
Sponsor Collaborator

wellwelwel commented Jul 21, 2024

Hi, @mrajasekar-godaddy 🙋🏻‍♂️

Currently I'm using promise-mysql which is a wrapper function of mysqljs

At first, I thought that promise-mysql was a typo of mysql2/promise, then I realized that this package does exist. Sorry for not noticing before.

So, everything works for me:

import mysql from 'promise-mysql';
import ssl from 'aws-ssl-profiles';

const connection = await mysql.createConnection({
  host: '***',
  user: '***',
  password: '***',
  database: '***',
  timezone: 'Z',
  ssl,
  // ssl: {
  //   ca: ssl.ca,
  //   rejectUnauthorized: false,
  // },
});

const [rows] = await connection.query('SELECT 1 + 1 AS `total`');

console.log(rows);

await connection.end();

About aws-ssl-profiles, it just exports an array of strings.

The error seems to come from a query, not a connection:

  • ER_BAD_FIELD_ERROR: Unknown column 'PJ.tier' in 'field list'.

Unfortunately, promise-mysql no longer seems to be maintained: CodeFoodPixels/node-promise-mysql#172.

@mrajasekar-godaddy
Copy link
Author

@wellwelwel Thanks for checking it and getting back. Appreciate it

But, I'm using CJM where I use const awsCaBundle = require('aws-ssl-profiles') and when I use it, I am not able to establish the connection.

Correct, this ER_BAD_FIELD_ERROR: Unknown column 'PJ.tier' in 'field list'. is a query error. But, the error which I get now is related to connection. i.e

errorMessage: 'Quit inactivity timeout', errorCode: 'PROTOCOL_SEQUENCE_TIMEOUT', errorDetail: {}, errorStack: 'Error: Quit inactivity timeout\n' +

@mrajasekar-godaddy
Copy link
Author

Also, Thanks for sharing that the 'promise-mysql' library is no longer active.

@wellwelwel
Copy link
Sponsor Collaborator

@mrajasekar-godaddy, If you can share your solution approach, that would be great 🙋🏻‍♂️

@wellwelwel wellwelwel closed this as not planned Won't fix, can't repro, duplicate, stale Jul 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants