Connecting via SSL
Security is very important when sending messages from the server to the client and vice versa. There are many data protection methods, including the use of SSL encryption to connect to a remote MySQL server from a Delphi application. MySQL supports data transfer via the TCP/IP protocol stack both using SSL encryption or without it.
Devart offers a solution called SecureBridge, which allows you to embed an SSL client into a Delphi or C++ Builder application to establish a secure connection to MySQL server. This tutorial demonstrates how to create a sample Delphi application that connects to MySQL using SSL as the encryption method.
Before connecting to MySQL via SSL, create SSL certificates as explained in the MySQL documentation and configure SSL parameters in the my.ini file.
To create an SSL connection to MySQL, set the T:Devart.MyDac.TMyConnectionOptions.Protocol. property in Options to mpSSL. It forces the application to only connect through SSL - if a connection attempt fails, an exeption is raised.
MyConnection.Options.Protocol := mpSSL;
After installing MyDAC and SecureBridge in your system, install the TCRSSLIOHandler component in RAD Studio to bind MyDAC with SecureBridge. The installation instructions are provided in the Readme.html, which is located by default in "My Documents\Devart\MyDAC for RAD Studio\Demos\TechnologySpecific\SecureBridge\DelphiXX".
Another way to embed SSL client functionality into your Delphi app, which uses MyDAC components to access MySQL, is by using the OpenSSL library that implements the SSL protocol and enables servers to securely communicate with their clients. The description of the SSL connection features without the SecureBridge IOHandler usage:
The following options must be set for SSL connection:
Note:The ssleay32.dll and libeay32.dll files are required to use the SSL protocol with the OpenSSL library.