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

Improve ConnectionOptions ssl documentation #3028

Closed
jrr opened this issue Sep 9, 2024 · 2 comments · Fixed by #3384
Closed

Improve ConnectionOptions ssl documentation #3028

jrr opened this issue Sep 9, 2024 · 2 comments · Fixed by #3384

Comments

@jrr
Copy link

jrr commented Sep 9, 2024

I struggled a bit today connecting to an Azure mysql server. I wanted to use TLS, but didn't want to supply certificates manually. (counting on the host's OS to already trust the remote server)

I got it working, but in hindsight I have a couple suggestions to flatten the speed bump and help folks in the future:

  • Allow ssl: true for people like me that want to turn it on but don't need to customize it
  • Make it really clear in the tooltip that:
    • An empty object ssl: {} means "Use SSL".
    • An absent field (no ssl:) means "Don't use SSL".
@mdshawn
Copy link

mdshawn commented Sep 13, 2024

const db = mysql.createConnection({
host: 'mysql-27b8c77e-devmujahidul-7992.h.aivencloud.com',
port: 17706,
user: 'avnadmin',
password: 'Actual Password', // Replace with your actual password
database: 'defaultdb',
ssl: {}
});

This is my aws mysql connection in mysql2.
I tried with Mysql Workbench and its working very perfectly. But my nodejs application giving so much pain. Always said:
throw err;
^

RangeError [ERR_OUT_OF_RANGE]: The value of "offset" is out of range. It must be >= 0 and <= 5. Received 9
at boundsError (node:internal/buffer:88:9)
at Buffer.readUInt32LE (node:internal/buffer:222:5)
at Packet.readInt32 (E:\Projects\IPTV WEB\node_modules\mysql2\lib\packets\packet.js:108:24)
at Handshake.fromPacket (E:\Projects\IPTV WEB\node_modules\mysql2\lib\packets\handshake.js:63:32)
at ClientHandshake.handshakeInit (E:\Projects\IPTV WEB\node_modules\mysql2\lib\commands\client_handshake.js:112:40)
at ClientHandshake.execute (E:\Projects\IPTV WEB\node_modules\mysql2\lib\commands\command.js:45:22)
at Connection.handlePacket (E:\Projects\IPTV WEB\node_modules\mysql2\lib\connection.js:481:34)
at PacketParser.onPacket (E:\Projects\IPTV WEB\node_modules\mysql2\lib\connection.js:97:12)
at PacketParser.executeStart (E:\Projects\IPTV WEB\node_modules\mysql2\lib\packet_parser.js:75:16)
at Socket. (E:\Projects\IPTV WEB\node_modules\mysql2\lib\connection.js:104:25) {
code: 'ERR_OUT_OF_RANGE',
fatal: true
}

Node.js v20.16.0

@pkuczynski
Copy link
Contributor

Since I was struggling myself, I put up a short documentation: #3384. @jrr any feedback?

If this goes through I might work on a patch with ssl: true.

@wellwelwel wellwelwel linked a pull request Feb 6, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants