Page 1 of 1

ssl_do_handshake=-1 error in delphi mydac

Posted: Wed 17 Aug 2016 12:53
by tanvir
Hi I am suing MyDAC 8.7.24 for RAD Studio 10.1.
I have a MySQL server and I have the client certificate and keys for SSL connection to the MYSQL server. In delphi that uses MyDAC for connecting to mysql, I can use:

Code: Select all

MySQL1Connection.SSLOptions.CACert := 'file location'
MySQL1Connection.SSLOptions.Cert := 'file location'
MySQL1Connection.SSLOptions.Key := 'file location'
MySQL1Connection.SSLOptions.ChipherList := 'All';
MySQL1Connection.Options.Protocol := mpSSL;
I also installed OpenSSL in my windows 10 (the development environment) and put the required dll files to the debug folder.
Unfortunately when I run the code, I get an exception showing
' ssl_do_handshake = -1 SSL_get_error(...,r2) = 1 r2 = -1'
I am completely stuck. I will be really grateful if you kindly give me an idea what to try next.

Re: ssl_do_handshake=-1 error in delphi mydac

Posted: Wed 17 Aug 2016 14:03
by ViktorV
This error is generated by OpenSSL library. This error may occur due to various reasons, for example:
- usage of an OpenSSL version that is not supported by MySQL server;
- usage of invalid certificate;
- an incorrect path to the certificate is specified.
For the problem investigation, please send a sample reproducing the problem to viktorv*devart*com, including certificates and the used OpenSSL libraries.
In addition, to solve the issue, you can use SecureBridge components. SecureBridge allows to establish secure connections within a single application without any external files. You can learn how to use SecureBridge with MyDAC in "Secure connections" topic of MyDAC help.

Re: ssl_do_handshake=-1 error in delphi mydac

Posted: Thu 18 Aug 2016 09:34
by tanvir
Thanks for your reply.
I am using the same key certificate for ssl connection using python in the same machine. The python is wroking perfectly. So, certificate and path is valid.
For OpenSSL, I am using the same version used in MySQL server. Unfortunately still I am getting same error.

As I am using a local mysql server, sending the files to you will not help.
Thanks a lot for the secure bridge option. But it looks like I can't find TMySSLIOHandler in my component list!

Re: ssl_do_handshake=-1 error in delphi mydac

Posted: Thu 18 Aug 2016 09:46
by ViktorV
The TMySSLIOHandler component is located in the mydacsbridge package. This package is included in the MyDAC demos. See the package installation instructions in the file "%MyDACDemos%\TechnologySpecific\SecureBridge\Readme.html", where %MyDACDemos% is the MyDAC Demo projects installation path on your computer.
To learn how to connect to MySQL server using SSL with SecureBridge in our documentation: https://www.devart.com/mydac/docs/?secu ... ctions.htm

Re: ssl_do_handshake=-1 error in delphi mydac

Posted: Thu 18 Aug 2016 10:07
by tanvir
Thanks.
While compiling mydacbridge240.bpl, I get the following error:
[dcc32 Fatal Error] CRSSHIOHandler.pas(250): F2039 Could not create output file 'c:\program files (x86)\embarcadero\studio\18.0\Lib\CRSSHIOHandler.dcu'

Re: ssl_do_handshake=-1 error in delphi mydac

Posted: Thu 18 Aug 2016 11:52
by ViktorV
This problem may occur if you don't have enough rights to create the CRSSHIOHandler.dcu unit in the 'c:\program files (x86)\embarcadero\studio\18.0\Lib\' directory. Please make sure you have the rights to create files in the 'c:\program files (x86)\embarcadero\studio\18.0\Lib\' directory.
To solve the issue, please try to run RAD Studio as administrator, then install and compile the mydacbridge240.bpl package.

Re: ssl_do_handshake=-1 error in delphi mydac

Posted: Thu 18 Aug 2016 13:59
by tanvir
Thanks!
It has been installed and I also have put the instalelled folder loaction to the path in RAD studio 10.1 Berlin option.

I have configured the code properly. But now two libraries are automatically added in the uses section of my code CRSSLIOHandler, MySSLIOHandler (they can't be removed, even if I remove it they appear again). Unfortunately it shows an error after compiling my code: "[dcc32 Fatal Error] IPLogReaderUnit.pas(10): F2613 Unit 'CRSSLIOHandler' not found."

Re: ssl_do_handshake=-1 error in delphi mydac

Posted: Thu 18 Aug 2016 14:27
by ViktorV
To solve the issue, please specify the path to the %MyDACDemos%\TechnologySpecific\SecureBridge directory in the "Library path" for All platform using the menu Tools->Environment Options->Delphi Options->Library. %MyDACDemos% is the MyDAC Demo projects installation path on your computer.

Re: ssl_do_handshake=-1 error in delphi mydac

Posted: Fri 19 Aug 2016 07:48
by tanvir
Thank you so much!
It is working now.
I have also uninstalled my open ssl from my laptop. Strangely my old code is also working. But I am almost ready to buy the secure bridge components. I think if I use secure bridge, I will not have to to supply the key and certificate files to the client with the .exe. Isn't it?

Re: ssl_do_handshake=-1 error in delphi mydac

Posted: Fri 19 Aug 2016 11:02
by ViktorV
If you are using certificates at authentication, you should deploy these files along with the application when using SecureBridge components as well.