MyDAC in Delphi cannot connect to MariaDB Server SSL handshake failed - Stack Overflow

I have an issue connecting my Delphi application to my MariaDB server via SSL. For that i'm using

I have an issue connecting my Delphi application to my MariaDB server via SSL. For that i'm using MyDAC with the SSL settings. Here my code:

// Method to establish a connection to the database with SSL support
procedure TSQLHelper.Connect(const Host, Database, User, Password: string; const SSLConnect: Boolean);
begin
  // Set connection parameters
  FHost := Host; // Hostname or IP address of the database server
  FDatabase := Database; // Name of the database to connect to
  FUsername := User; // Database username
  FPassword := Password; // Database password
  FSSLConnect := SSLConnect;

  try
    // Uses an SSL Connection if set to true
    if SSLConnect then
    begin
      // Set the protocol to SSL for secure connection
      FConnection.Options.Protocol := TMyProtocol.mpSSL;

      FConnection.SSLOptions.CipherList := 'All'; // Enable all cipher suites
    end;

    // Assign connection parameters to the MyDAC connection object
    FConnection.Server := FHost;
    FConnection.Database := FDatabase;
    FConnection.Username := FUsername;
    FConnection.Password := FPassword;
    FConnection.Options.UseUnicode := True; // Ensure Unicode support is enabled

    // Attempt to connect to the database
    FConnection.Connected := True;
  except
    on E: Exception do
    begin
      // Handle connection errors
      FLastErrNo := 1001; // General error code for connection issues
      FLastError := 'Error connecting to Server ' + FHost + ' with User ' + FUsername + ': ' + E.Message; // Detailed error message
    end;
  end;
end;

I enforced the SSL connection with "REQUIRED" in my MariaDB server so the SSL connection is established via the server. I get the following error trying to connect: "Could not connect to the database: Error connecting to Server 192.168.184.130 with User testuser: SSL_do_handshake = -1 SSL_get_error(..., r2) = 1 r2 = -1"

What i did test:

  1. Checked if the certs on the server are valid
  2. Connected to the server via NaviCat and HeidiSQL (Enabeling SSL but not providing any certificates). Both worked and are showing "Ssl_cipher ECDHE-RSA-AES256-GCM-SHA384"
  3. Changed "FConnection.SSLOptions.CipherList := 'All';" to 'ECDHE-RSA-AES256-GCM-SHA384'
  4. Checked if the credentials are handed over to the FConnection.
  5. Set up an SQL User with ALL Priviliges.
  6. Used Google and ChatGPT to research the error codes but both weren't helpful
  7. Checked if SSLConnect is set to true (which it is).
  8. I have switched the libeay32.dll and ssleay32.dll to the ones in the NaviCat installation folder.

I have run out of ideas. Any tips are appreciated!

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1743959615a4536433.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信