multitheftauto / mtasa-blue

Multi Theft Auto is a game engine that incorporates an extendable network play element into a proprietary commercial single-player game.
https://multitheftauto.com
GNU General Public License v3.0
1.38k stars 424 forks source link

MySQL SSL connection error: unknown error number #3270

Closed Xenius97 closed 7 months ago

Xenius97 commented 9 months ago

Describe the bug

[2023-12-15 09:25:20] WARNING: [core]\ex_mysql\server\classes\mysql.lua:27: Bad usage @ 'dbConnect' [SSL connection error: unknown error number]

I think its caused by https://github.com/multitheftauto/mtasa-blue/commit/6f1ccc8e778166025d19867ac043f891ad2c238f

Steps to reproduce

dbConnect()

Version

22331

Additional context

No response

Relevant log output

No response

Security Policy

Xenius97 commented 9 months ago

mysql log:

2023-12-15T08:23:52.857366Z 0 [System] [MY-010116] [Server] e:\wamp64\bin\mysql\mysql8.0.31\bin\mysqld.exe (mysqld 8.0.31) starting as process 11848
2023-12-15T08:23:52.914364Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-12-15T08:23:53.873515Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-12-15T08:23:54.591678Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2023-12-15T08:23:54.592137Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2023-12-15T08:23:54.621375Z 0 [System] [MY-010931] [Server] e:\wamp64\bin\mysql\mysql8.0.31\bin\mysqld.exe: ready for connections. Version: '8.0.31'  socket: ''  port: 3306  MySQL Community Server - GPL.
2023-12-15T21:12:51.100215Z 0 [System] [MY-013105] [Server] e:\wamp64\bin\mysql\mysql8.0.31\bin\mysqld.exe: Normal shutdown.
Xenius97 commented 9 months ago

Seems like disabling SSL solved

[mysqld]
ssl=off
TracerDS commented 9 months ago

Seems like disabling SSL solved

[mysqld]
ssl=off

Disabling SSL might be a security issue in the near future. Its better to fix it from the origin instead of taking the easy way out

Xenius97 commented 9 months ago

Okay, i think latest libmysql update broke mysql SSL, thats why didn't work.

Lpsd commented 9 months ago

I don't think SSL ever worked with our MySQL implementation, see #2772

Xenius97 commented 9 months ago

No errors with older server version

Allerek commented 9 months ago

No errors with older server version

Quick guess that in older versions when you tried SSL but failed it just tried non-ssl connection. Now it might try to enforce SSL and not fall back to non-ssl on failure.

theSarrum commented 9 months ago

I have an idea why this is happening. All this time, an old version of libmysql.dll (6.1.3.0) was shipped with the Windows server. After this change botder noticed it and updated the old files.

You might ask, what could have changed between 6.1.3.0 and the current version (6.1.11.0)? My guess is that the issue is that SSL was not used before, but with the new version it is now enabled by default.

Why is there a connection issue? The issue is that the MySQL connector supports only TLSv1 and TLSv1.1 protocols when compiled with yaSSL. Starting from MySQL 8.0.28, TLSv1 and TLSv1.1 are no longer supported.

If this is indeed the case, there are 2 possible solutions: 1) Build libmysql with OpenSSL, which would enable TLSv1.2 support; 2) Disable TLS encryption:

int ssl_mode = SSL_MODE_DISABLED;
mysql_options(m_handle, MYSQL_OPT_SSL_MODE, &ssl_mode);

If we choose the second option, it is probably better to add an option for dbConnect.

TracerDS commented 9 months ago

We should go with the first one. Not having SSL is... A shame to say at least

emmmhx commented 8 months ago

@Xenius97 What version of mysql server you are using now? I need a stable one for the server.

Xenius97 commented 8 months ago

@Xenius97 What version of mysql server you are using now? I need a stable one for the server.

8.2, latest WampServer (local)

TheNormalnij commented 8 months ago

Some linux servers have related issue

ERROR: Could not load /game/mods/deathmatch/dbconmy.so - libssl.so.1.1: cannot open shared object file: No such file or directory
[23-12-28 21:34:49] WARNING: [System]/nelski/login_server.lua:4: Bad usage @ 'dbConnect' [Could not connect]
TracerDS commented 6 months ago

When the MySQL server enforces SSL, this will still happen again no matter if you enable SSL via options or not