Topic: [Script] MySQL with SSL

An example, how to activate SSL for the MySQL.
Works beginning from version 4.4

procedure Form1_OnShow (Sender: TObject; Action: string);
begin
    {$MySQL disable_connectdialog}

     frmWait.Show;
     Application.ProcessMessages;

     // how to setup MySQL SSL
     // https://dev.mysql.com/doc/refman/8.0/en/encrypted-connections.html

     // certificates for the MySQL server you can find in the folder "Certificates for MySQL server"
     // these certificates just for test, you must generate own certificates
     // the Common Name value used for the server and client certificates/keys must each differ from the Common Name value used for the CA certificate. Otherwise, the certificate and key files will not work for servers compiled using OpenSSL.
     Form1.MySQLConnection.SSLOptions.CACert := ExtractFilePath(Application.ExeName )+'ca.pem';
     Form1.MySQLConnection.SSLOptions.Cert := ExtractFilePath(Application.ExeName )+'client-cert.pem';
     Form1.MySQLConnection.SSLOptions.Key := ExtractFilePath(Application.ExeName )+'client-key.pem';
     Form1.MySQLConnection.Options.Protocol := mpSSL;


     Form1.MySQLConnection.Server := '127.0.0.1';
     Form1.MySQLConnection.Port := 3306;
     Form1.MySQLConnection.Username := 'root';
     Form1.MySQLConnection.Password := 'root';
     Form1.MySQLConnection.Database := 'mvd';

     try
         Form1.MySQLConnection.Connect;
     except
         frmWait.Close;
         ShowMessage('Can''t connect to database.');
         Form1.Close;
     end;

     if Form1.MySQLConnection.Connected then
     begin
         UpdateDatabase(''); // to fill ComboBoxes
         Form1.TableGrid1.dbUpdate; // if you have TableGrid on first form with option "Enable auto execution", you should call method dbUpdate manually
     end;
     frmWait.Close;
end;



Project example:

Post's attachments

Attachment icon MySQL SSL.zip 12.8 kb, 942 downloads since 2018-05-16 

Dmitry.

Re: [Script] MySQL with SSL

thanks

Re: [Script] MySQL with SSL

Has this example worked for anyone?

Thanks.

Re: [Script] MySQL with SSL

imathok wrote:

Has this example worked for anyone?

Thanks.

не сработает , на сколько я помню, для собственного соединения нужно собирать файлы со своими ключами

https://www.emaro-ssl.ru/blog/convert-s … e-formats/

Re: [Script] MySQL with SSL

What is mpSSL ?
Are there any other options?