Unidac + mpssl + OpenSSL 1.1.0

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Nils
Posts: 9
Joined: Mon 29 Oct 2012 12:31

Unidac + mpssl + OpenSSL 1.1.0

Post by Nils » Thu 27 Aug 2020 13:00

When i try to connect to a MySQL Database (Version 5.7.29) with mpssl as Protocol setting and 'libcrypto-1_1.dll' and 'libssl-1_1.dll' present i get the following exception:

Access violation at address 57484016 in module 'libcrypto-1_1.dll'. Read of address 80004F00.

If the 'libcrypto-1_1.dll' and 'libssl-1_1.dll' are not present and using 'libeay32.dll' and 'ssleay32.dll' it works.

Delphi version 10.4 with Update 3
UniDAC Version 8.3.1 - the previous Version 8.2.5 did the same
Windows 10 with a 32bit program and 32bit OPENSSL DLLs

Is there any way to tell UniDAC to not use the OpenSSL 1.1 DLLs. As soon as they are in a Windows environment path they will be preferred by UniDAC.

Error Trace:

[1319D708]{unidac270.bpl} Uni. + $0
[1319F1EB]{unidac270.bpl} Uni.TUniConnection.DoConnect + $43
[1331A14A]{dac270.bpl } Crviotcpssl.vio_verify_callback + $82
[13319D47]{dac270.bpl } Crviotcpssl.TCRVioTcpSSL.SetisSecure + $107
[1C12855C]{myprovider270.bpl} Mysqlsessionuni.TMySqlSession.SetIsUTF8 + $188
[1C128BDE]{myprovider270.bpl} Mysqlsessionuni.TMySqlSession.Connect + $66E
[1C12E86A]{myprovider270.bpl} Mysqlapidirectuni.TMySQLAPIDirect.mysql_real_connect + $62
[1C13A324]{myprovider270.bpl} Myclassesuni.TMySQLConnection.Connect + $24C
[1329A737]{dac270.bpl } Dbaccess.TCustomDAConnection.DoConnect + $FB
[1319F1D7]{unidac270.bpl} Uni.TUniConnection.DoConnect + $2F
[1329AB45]{dac270.bpl } Dbaccess.TCustomDAConnection.PerformConnect + $51
[131156EB]{dcldac270.bpl} Daconnectioneditor.TDAConnectionEditorForm.PerformConnect + $B
[131154AF]{dcldac270.bpl} Daconnectioneditor.TDAConnectionEditorForm.btConnectClick + $3F
[50CF731F]{vcl270.bpl } Vcl.Controls.TControl.Click (Line 7596, "Vcl.Controls.pas" + 9) + $8
[50D1ECBA]{vcl270.bpl } Vcl.StdCtrls.TCustomButton.Click (Line 5602, "Vcl.StdCtrls.pas" + 3) + $2
[50D1FE38]{vcl270.bpl } Vcl.StdCtrls.TCustomButton.CNCommand (Line 6237, "Vcl.StdCtrls.pas" + 1) + $B
[50CF6DC6]{vcl270.bpl } Vcl.Controls.TControl.WndProc (Line 7480, "Vcl.Controls.pas" + 91) + $6
[50CF8882]{vcl270.bpl } Vcl.Controls.TControl.GetStyleName (Line 8510, "Vcl.Controls.pas" + 1) + $8
[5005A240]{rtl270.bpl } System.@GetMem (Line 4829, "System.pas" + 20) + $0
[50061CBE]{rtl270.bpl } System.@NewUnicodeString (Line 25426, "System.pas" + 10) + $0
[50062159]{rtl270.bpl } System.@UStrAsg (Line 26416, "System.pas" + 19) + $0
[5005A25C]{rtl270.bpl } System.@FreeMem (Line 4877, "System.pas" + 20) + $0
[50061DDD]{rtl270.bpl } System.@UStrArrayClr (Line 25795, "System.pas" + 16) + $0
[50CF895F]{vcl270.bpl } Vcl.Controls.TControl.IsCustomStyleActive (Line 8526, "Vcl.Controls.pas" + 8) + $15
[50CFBCAE]{vcl270.bpl } Vcl.Controls.TWinControl.WndProc (Line 10423, "Vcl.Controls.pas" + 168) + $6
[50D1E914]{vcl270.bpl } Vcl.StdCtrls.TButtonControl.WndProc (Line 5432, "Vcl.StdCtrls.pas" + 13) + $4
[50CF6A00]{vcl270.bpl } Vcl.Controls.TControl.Perform (Line 7258, "Vcl.Controls.pas" + 10) + $8
[50CFBE0F]{vcl270.bpl } Vcl.Controls.DoControlMsg (Line 10492, "Vcl.Controls.pas" + 12) + $11
[50CFCA07]{vcl270.bpl } Vcl.Controls.TWinControl.WMCommand (Line 10769, "Vcl.Controls.pas" + 1) + $5
[50CF6DC6]{vcl270.bpl } Vcl.Controls.TControl.WndProc (Line 7480, "Vcl.Controls.pas" + 91) + $6
[50CFBDBA]{vcl270.bpl } Vcl.Controls.TWinControl.DefaultHandler (Line 10464, "Vcl.Controls.pas" + 30) + $19
[50CF6DC6]{vcl270.bpl } Vcl.Controls.TControl.WndProc (Line 7480, "Vcl.Controls.pas" + 91) + $6
[50CF8882]{vcl270.bpl } Vcl.Controls.TControl.GetStyleName (Line 8510, "Vcl.Controls.pas" + 1) + $8
[5005A240]{rtl270.bpl } System.@GetMem (Line 4829, "System.pas" + 20) + $0
[50061CBE]{rtl270.bpl } System.@NewUnicodeString (Line 25426, "System.pas" + 10) + $0
[50062159]{rtl270.bpl } System.@UStrAsg (Line 26416, "System.pas" + 19) + $0
[5005A25C]{rtl270.bpl } System.@FreeMem (Line 4877, "System.pas" + 20) + $0
[50061DDD]{rtl270.bpl } System.@UStrArrayClr (Line 25795, "System.pas" + 16) + $0
[50CF895F]{vcl270.bpl } Vcl.Controls.TControl.IsCustomStyleActive (Line 8526, "Vcl.Controls.pas" + 8) + $15
[50CFBCAE]{vcl270.bpl } Vcl.Controls.TWinControl.WndProc (Line 10423, "Vcl.Controls.pas" + 168) + $6
[500605D4]{rtl270.bpl } System.TMonitor.Enter (Line 19345, "System.pas" + 4) + $2
[50CF8882]{vcl270.bpl } Vcl.Controls.TControl.GetStyleName (Line 8510, "Vcl.Controls.pas" + 1) + $8
[50CFB230]{vcl270.bpl } Vcl.Controls.TWinControl.MainWndProc (Line 10120, "Vcl.Controls.pas" + 3) + $6
[50181184]{rtl270.bpl } System.Classes.StdWndProc (Line 17989, "System.Classes.pas" + 8) + $0
[21895A87]{vclactnband270.bpl} Vcl.ActnMenus.CallWindowHook (Line 759, "Vcl.ActnMenus.pas" + 20) + $F
[50CF6DC6]{vcl270.bpl } Vcl.Controls.TControl.WndProc (Line 7480, "Vcl.Controls.pas" + 91) + $6
[50F4C99F]{vcl270.bpl } Vcl.Styles.TCustomStyle.SourceLoaded (Line 3310, "Vcl.Styles.pas" + 1) + $13
[5005FF43]{rtl270.bpl } System.TObject.Dispatch (Line 18563, "System.pas" + 11) + $0
[50DF7202]{vcl270.bpl } Vcl.Themes.TStyleHook.WndProc (Line 7394, "Vcl.Themes.pas" + 38) + $6
[50DF6A26]{vcl270.bpl } Vcl.Themes.TStyleHook.HandleMessage (Line 7107, "Vcl.Themes.pas" + 20) + $6
[50F4D17E]{vcl270.bpl } Vcl.Styles.TStyleEngine.HandleMessage (Line 3598, "Vcl.Styles.pas" + 22) + $B
[50DF73F8]{vcl270.bpl } Vcl.Themes.TMouseTrackControlStyleHook.WndProc (Line 7502, "Vcl.Themes.pas" + 0) + $0
[50E50389]{vcl270.bpl } Vcl.Forms.TCustomForm.WndProc (Line 4569, "Vcl.Forms.pas" + 1) + $37
[50E509D5]{vcl270.bpl } Vcl.Forms.TCustomForm.WndProc (Line 4781, "Vcl.Forms.pas" + 213) + $5
[50CFBDBA]{vcl270.bpl } Vcl.Controls.TWinControl.DefaultHandler (Line 10464, "Vcl.Controls.pas" + 30) + $19
[50CF776C]{vcl270.bpl } Vcl.Controls.TControl.WMLButtonUp (Line 7729, "Vcl.Controls.pas" + 1) + $6
[50CF6DC6]{vcl270.bpl } Vcl.Controls.TControl.WndProc (Line 7480, "Vcl.Controls.pas" + 91) + $6
[50F4C99F]{vcl270.bpl } Vcl.Styles.TCustomStyle.SourceLoaded (Line 3310, "Vcl.Styles.pas" + 1) + $13
[50F4C8E0]{vcl270.bpl } Vcl.Styles.TCustomStyle.GetEnabled (Line 3290, "Vcl.Styles.pas" + 0) + $4
[50DF394F]{vcl270.bpl } Vcl.Themes.TStyleManager.GetIsCustomStyleActive (Line 5646, "Vcl.Themes.pas" + 0) + $7
[50DF7615]{vcl270.bpl } Vcl.Themes.TCustomStyleEngine.HookCBProc (Line 7563, "Vcl.Themes.pas" + 3) + $0
[50DF77C6]{vcl270.bpl } Vcl.Themes.TCustomStyleEngine.HookCBProc (Line 7614, "Vcl.Themes.pas" + 54) + $18
[50CF8882]{vcl270.bpl } Vcl.Controls.TControl.GetStyleName (Line 8510, "Vcl.Controls.pas" + 1) + $8
[5005A240]{rtl270.bpl } System.@GetMem (Line 4829, "System.pas" + 20) + $0
[50061CBE]{rtl270.bpl } System.@NewUnicodeString (Line 25426, "System.pas" + 10) + $0
[50062159]{rtl270.bpl } System.@UStrAsg (Line 26416, "System.pas" + 19) + $0
[50CFB41F]{vcl270.bpl } Vcl.Controls.TWinControl.IsControlMouseMsg (Line 10176, "Vcl.Controls.pas" + 1) + $9
[50CF895F]{vcl270.bpl } Vcl.Controls.TControl.IsCustomStyleActive (Line 8526, "Vcl.Controls.pas" + 8) + $15
[50CFBCAE]{vcl270.bpl } Vcl.Controls.TWinControl.WndProc (Line 10423, "Vcl.Controls.pas" + 168) + $6
[50D1E914]{vcl270.bpl } Vcl.StdCtrls.TButtonControl.WndProc (Line 5432, "Vcl.StdCtrls.pas" + 13) + $4
[50CFB230]{vcl270.bpl } Vcl.Controls.TWinControl.MainWndProc (Line 10120, "Vcl.Controls.pas" + 3) + $6
[50181184]{rtl270.bpl } System.Classes.StdWndProc (Line 17989, "System.Classes.pas" + 8) + $0
[50E5A71F]{vcl270.bpl } Vcl.Forms.TApplication.ProcessMessage (Line 11002, "Vcl.Forms.pas" + 23) + $1
[50E5A762]{vcl270.bpl } Vcl.Forms.TApplication.HandleMessage (Line 11032, "Vcl.Forms.pas" + 1) + $4
[50E55B62]{vcl270.bpl } Vcl.Forms.TCustomForm.ShowModal (Line 7713, "Vcl.Forms.pas" + 33) + $5
[13114E4A]{dcldac270.bpl} Daconnectioneditor.TDAConnectionEditorForm.SetComponent + $E
[13100918]{dcldac270.bpl} Crdesign.TCRComponentEditor.ShowEditorEx + $8C
[13100866]{dcldac270.bpl} Crdesign.TCRComponentEditor.ShowEditor + $32
[1311FE4A]{dcldac270.bpl} Dadesign.TDAComponentEditor.ShowEditor + $46
[13100C49]{dcldac270.bpl} Crdesign.TCRComponentEditor.Edit + $D
[2109AAB9]{designide270.bpl} ComponentDesigner.TInternalItem.Edit (Line 7793, "ComponentDesigner.pas" + 1) + $F
[2105119C]{designide270.bpl} Designer.TDesigner.Edit (Line 1024, "Designer.pas" + 0) + $4
[21053473]{designide270.bpl} Designer.TDesigner.MouseDown (Line 1724, "Designer.pas" + 50) + $6
[5288C181]{vcldesigner270.bpl} VCLSurface.TComponentToolWindow.WndProc (Line 1641, "VCLSurface.pas" + 16) + $32
[5288CC87]{vcldesigner270.bpl} VCLSurface.TContainer.WndProc (Line 1959, "VCLSurface.pas" + 39) + $6
[5288BFA3]{vcldesigner270.bpl} VCLSurface.TDesignerToolWindow.MainWndProc (Line 1576, "VCLSurface.pas" + 2) + $7
[50181184]{rtl270.bpl } System.Classes.StdWndProc (Line 17989, "System.Classes.pas" + 8) + $0
[50E5A71F]{vcl270.bpl } Vcl.Forms.TApplication.ProcessMessage (Line 11002, "Vcl.Forms.pas" + 23) + $1
[50E5A762]{vcl270.bpl } Vcl.Forms.TApplication.HandleMessage (Line 11032, "Vcl.Forms.pas" + 1) + $4
[50E5AA95]{vcl270.bpl } Vcl.Forms.TApplication.Run (Line 11170, "Vcl.Forms.pas" + 26) + $3
[0051E104]{bds.exe } bds.bds (Line 222, "" + 13) + $2

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: Unidac + mpssl + OpenSSL 1.1.0

Post by ViktorV » Mon 07 Sep 2020 04:38

UniDAC uses the following OpenSSL libraries names: first - libcrypto-1_1.dll and libssl-1_1.dll; second - libeay32.dll and ssleay32.dll.
UniDAC will look for the files in directories on your machine, in this order:
- The directory from which your application is loaded.
- The. //System32 system folder.
- The //SysWOW64 folder on a 64-bit system.
- The //Windows folder.
- Current workspace.
- Folders listed in the РАТН environment variable.
Therefore, to solve the issue, you can try placing the libeay32.dll and ssleay32.dll files in the directory with the executable file of your application.
Also to solve the issue, you can rename libeay32.dll and ssleay32.dll into libcrypto-1_1.dll and libssl-1_1.dll correspondingly.
To investigate the issue, we need a sample project or the configured environment where the issue can reproduced. If the issue is caused by our product, we'll try to fix it as soon as possible. Please create and send to us through the contact form https://devart.com/company/contactform.html a complete example demonstrating the behavior you indicated.

But using OpenSSL libraries to create an SSL connection with MySQL server can lead to various problems. For example, OpenSSL version can be not supported by MySQL server, the bitness of the supplied OpenSSL libraries can differ from the bitness of your application, etc.
To solve the issue, you can use the SecureBridge components. SecureBridge allows you to establish secure connections within a single application without any external files. You can learn how to use SecureBridge with MyDAC in the "Secure connections" topic of MyDAC help.
The ability to create an SSL connection with MySQL server primarily depends on the server settings, which must be configured accordingly: SSL support is enabled and a user is created with the requirement to connect via SSL. Therefore, to solve your problem, you should create a user with the requirement to connect via SSL. The requirement for the use of certificates when setting up an SSL connection depends on the user's settings. For more information on this issue, please refer to the MySQL server documentation. To obtain the necessary data for setting up SSL, please contact the technical support of MySQL server.
To solve your task, please place on the form the TCRSSLIOHandler component and assign it to the TUniConnection.IOHandler property.
The TCRSSLIOHandler component is located in the dcldacsbridgeXXX package. This package is included in the UniDAC demos. See the package installation instructions in the file "%UniDACDemos%\TechnologySpecific\SecureBridge\Readme.html", where %UniDACDemos% is the UniDAC Demo projects installation path on your computer.

Nils
Posts: 9
Joined: Mon 29 Oct 2012 12:31

Re: Unidac + mpssl + OpenSSL 1.1.0

Post by Nils » Mon 05 Oct 2020 08:19

Sorry for not replying in a long time. I'm not able to reproduce the error at will. I made a test program with the following files:

|
|- UnidacOpenSSLProb.exe
|- libcrypto-1_1.dll
|- libssl-1_1.dll

Running the exe on my PC I get the error:

Code: Select all

[Window Title]
Unidacopensslprob

[Content]
Access violation at address 77BD6DC6 in module 'libcrypto-1_1.dll'. Read of address 88000A00

[OK]
Running the program on another test pc with the exact same files in the folder i get the error:

Code: Select all

[Window Title]
Unidacopensslprob

[Content]
OpenSSL client library couldn't be loaded. Please place libeay32.dll and ssleay32.dll (or libssl32.dll) to system folder (included to PATH) or to the folder with executable unit of main program.

[OK]

Checking the program with the process explorer on the first machine i can see that it is trying to use 'libcrypto-1_1.dll' from the folder and not from anywhere else.

So could you give me a hint, under which circumstances which dlls are used. The target Database is the same from both machines.

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: Unidac + mpssl + OpenSSL 1.1.0

Post by ViktorV » Thu 08 Oct 2020 15:20

The error about "OpenSSL client library couldn't be loaded" can occur when you use client libraries, bitness of which does not match your application bitness.
The bitness of the used client libraries must match your application bitness, regardless of the bitness of the server you are using.
As we wrote earlier, this issue won't occur if you use SecureBridge because you won't need any client libraries.

Post Reply