Issue #1986: do not set CLIENT_SSL flag with libmariadb, which seems to cause a "bad handshake" in mysql_real_connect()

This commit is contained in:
Ansgar Becker
2025-03-16 13:40:52 +01:00
parent 888a021d39
commit 09edb5448a
2 changed files with 33 additions and 24 deletions

View File

@ -277,7 +277,7 @@ type
mysql_info: function(Handle: PMYSQL): PAnsiChar; stdcall;
mysql_num_fields: function(Result: PMYSQL_RES): Integer; stdcall;
mysql_num_rows: function(Result: PMYSQL_RES): Int64; stdcall;
mysql_options: function(Handle: PMYSQL; Option: Integer; arg: PAnsiChar): Integer; stdcall;
mysql_options: function(Handle: PMYSQL; Option: Integer; arg: Pointer): Integer; stdcall;
mysql_optionsv: function(Handle: PMYSQL; Option: Integer; arg, val: PAnsiChar): Integer; stdcall;
mysql_ping: function(Handle: PMYSQL): Integer; stdcall;
mysql_real_connect: function(Handle: PMYSQL; const Host, User, Passwd, Db: PAnsiChar; Port: Cardinal; const UnixSocket: PAnsiChar; ClientFlag: Cardinal): PMYSQL; stdcall;
@ -292,8 +292,8 @@ type
mysql_warning_count: function(Handle: PMYSQL): Cardinal; stdcall;
const
INVALID_OPT = -1;
MYBOOL_FALSE: Byte = 0;
MYBOOL_TRUE: Byte = 1;
MYBOOL_FALSE: Integer = 0;
MYBOOL_TRUE: Integer = 1;
protected
procedure AssignProcedures; override;
public
@ -316,6 +316,7 @@ type
SSL_MODE_VERIFY_CA,
SSL_MODE_VERIFY_IDENTITY: Integer;
constructor Create(DllFile, DefaultDll: String); override;
function IsLibMariadb: Boolean;
end;
var
MySQLKeywords: TStringList;
@ -3154,7 +3155,7 @@ begin
SSL_MODE_REQUIRED := 3;
SSL_MODE_VERIFY_CA := 4;
SSL_MODE_VERIFY_IDENTITY := 5;
if ExtractFileName(FDllFile).StartsWith('libmariadb', True) then begin
if IsLibMariadb then begin
// Differences in libmariadb
MYSQL_OPT_SSL_VERIFY_SERVER_CERT := 21;
MARIADB_OPT_TLS_VERSION := 7005;
@ -3173,6 +3174,12 @@ begin
end;
end;
function TMySQLLib.IsLibMariadb: Boolean;
begin
// libmariadb used (not libmysql) ?
Result := ExtractFileName(FDllFile).StartsWith('libmariadb', True);
end;
procedure TMySQLLib.AssignProcedures;
begin
AssignProc(@mysql_affected_rows, 'mysql_affected_rows');