Could not load SSL library - dll not found - delphi

In my Delphi (10.3 community edition) program, I try to use Indy with the OpenSSL library, but I receive an error
Could not load SSL library
My OpenSSL library is version 1.0.2u and I put the libeay32.dll and ssleay32.dll files in my program EXE directory, and in Windows\SYSWOW64 and Windows\System32.
I have installed the Embarcadero Delphi Patch RS1033_Indy_SSL_Patch.
After the exception, I call WhichFailedToLoad() and the result is
Failed to load libeay32.dll
This is a simple program that raises the exception:
url := 'https://www.google.it';
try
Web := TIdHTTP.Create(nil);
hIOHand := TIdSSLIOHandlerSocketOpenSSL.Create(nil);
hIOHand.SSLOptions.SSLVersions := [sslvTLSv1,sslvTLSv1_1,sslvTLSv1_2,sslvSSLv23];
Web.IOHandler := hIOHand;
Web.Request.UserAgent := INET_USERAGENT; //Custom user agent string
Web.RedirectMaximum := INET_REDIRECT_MAX; //Maximum redirects
Web.HandleRedirects := INET_REDIRECT_MAX <> 0; //Handle redirects
Web.ReadTimeOut := INET_TIMEOUT_SECS * 1000; //Read timeout msec
try
Sito := Web.Get(Url);
Sito := DateToStr(Web.Response.LastModified) + Sito;
except
on e : exception do
stg := WhichFailedToLoad();
end;
finally
Web.Free;
end;
Can you help me to solve the problem?

I put the libeay32.dll and ssleay32.dll files in my program EXE directory
That is fine. That is the 1st place the OS will look for them.
and in Windows\SYSWOW64 and in Windows\System32
Don't do that! Non-system files do not belong there. ESPECIALLY if you are putting the same files in both folders, since Windows\SYSWOW64 is meant only for 32bit files and Windows\System32 is meant only for 64bit files.
Failed to load libeay32.dll
That means Windows could not load that DLL into memory at all. Probably because it couldn't find the dependent ssleay32.dll file, but more likely because you mixed up the 32bit and 64bit versions of the DLLs. If your app is compiled as a 32bit EXE, you must use the 32bit version of both DLLs. If your app is compiled as a 64bit EXE, you must use the 64bit version of both DLLs.

Related

Why the compiler is unable to load the library name dbexpint.dll?

I'm a new user o Delphi 10.2 Tokyo (trial version) when I compile the program source code this error message appears:
Unable to load dbexpint.dll (ErrorCode 126). It may be missing from the system path.
This code should access a Firebird database, I have Firebird Client 3.0 installed on my machine. inside the installation folder I have the DLLs:
FBCLIENT.DLL
MSVCP100.DLL
MSVCR100.DLL
Below is part of the source code.
unit uDataModule;
interface
uses
SysUtils, Classes, DBXCommon, DB, DBClient, SimpleDS, SqlExpr, FMTBcd,
ADODB, Data.DBXInterBase, Data.DBXOracle;
...
procedure TDM.DataModuleCreate(Sender: TObject);
var
strPath: String;
begin
//Conex?o Firebird SPIRIDON
SQLSpiridonConnection.Params.Clear;
SQLSpiridonConnection.Params.Values['DatabaseServer'] := 'Interbase';
SQLSpiridonConnection.Params.Values['Database'] := 'XXXXXXXXXX:f:\dados\database\XXXXXXXXXXXX.FDB';
SQLSpiridonConnection.Params.Values['SQLDialect'] := '3';
SQLSpiridonConnection.Params.Values['DriverName'] := 'Interbase';
SQLSpiridonConnection.Params.Values['VendorLib'] := 'gds32.dll';
SQLSpiridonConnection.Params.Values['User_Name'] := 'XXXXXXXX';
SQLSpiridonConnection.Params.Values['Password'] := 'XXXXXXXX';
SQLSpiridonConnection.Params.Values['LibraryName'] := 'dbexpint.dll';
SQLSpiridonConnection.Params.Values['GetDriverFunc'] :=
'getSQLDriverINTERBASE';
SQLSpiridonConnection.Connected:= True;
I tried to download the DLL and put it in the system32 and wow64 folders, but it was not effective.
I tried changing the reference from the Library name line to dbxint.dll, but the following error appears:
DBX Error: Driver could not be properly initialized. Client library may be missing, not installed properly, of the wrong version, or the driver may be missing from the system path.
I don't know what's wrong and how I can solve it. Please, can you guys help me?
dbexpint.dll is the dbExpress Interbase driver for (old) Delphi versions from Delphi 6 to Delphi 2005. It could also be used to connect with Firebird databases, while newer Delphi versions use separate drivers for each one.
This driver is not compatible with Delphi versions 2006 and later. Instead, Delphi 10.2 now uses dbxint.dll for Interbase, and dbxfb.dll for Firebird.
The params of dbxfb.dll are similar to that of dbexpint.dll.
If you create a new form, drop a TSQLConnection on it and select FBConnection as the value of the ConnectionName property, then the Driver property will automatically be assigned with the needed value Firebird, and the Params property will also be populated with suitable values:
object SQLConnection1: TSQLConnection
ConnectionName = 'FBConnection'
DriverName = 'Firebird'
Params.Strings = (
'DriverName=Firebird'
'Database=database.fdb'
'RoleName=RoleName'
'User_Name=sysdba'
'Password=masterkey'
'ServerCharSet='
'SQLDialect=3'
'ErrorResourceFile='
'LocaleCode=0000'
'BlobSize=-1'
'CommitRetain=False'
'WaitOnLocks=True'
'IsolationLevel=ReadCommitted'
'Trim Char=False')
Left = 312
Top = 172
end
Note: As mentioned by #DavidHeffernan in the comments, don't put DLLs into system directories. Better put it in the same folder as your exe file.
Thanks guys for the help.
I found a way to fix the error:
Actually the dbexpint.dll driver only worked on the older versions of Delphi. The current driver is dbxfb.dll for connections to the Firebird database.
Firstly I changed the lines of code as below.
SQLSpiridonConnection.Params.Clear;
SQLSpiridonConnection.Params.Values['DatabaseServer'] := 'Firebird';
SQLSpiridonConnection.Params.Values['Database'] := 'xxxxxxxxxxxxx:f:\dados\database\xxxxxxxxxx.FDB';
SQLSpiridonConnection.Params.Values['SQLDialect'] := '3';
SQLSpiridonConnection.Params.Values['DriverName'] := 'Firebird';
SQLSpiridonConnection.Params.Values['VendorLib'] := 'fbclient.dll';
SQLSpiridonConnection.Params.Values['User_Name'] := 'SYSDBA';
SQLSpiridonConnection.Params.Values['Password'] := 'xxxxxxx';
SQLSpiridonConnection.Params.Values['LibraryName'] := 'dbxfb.dll';
SQLSpiridonConnection.Params.Values['GetDriverFunc'] := 'getSQLDriverINTERBASE';
SQLSpiridonConnection.Connected:= True;
After that I inserted these dlls into the Firebird installation folder.
borlndmm.dll
dbxfb.dll
midas.dll
fbclient.dll this dll is already installed in the folder
The other dlls are inside the delphi installation folder.
Ex: C: \ Program Files (x86) \ Embarcadero \ Studio \ 19.0 \ bin
OBS: #DavidHeffernan Yes I did already asked this question, thanks for your comment

Indy "Could not load SSL library" Delphi XE2 IW14

I know this question has been asked before but none of the answers seem to be appropriate for this situation.
I'm using a TIdHttp component with an SSL handler. My code is as follows:
idHTTPClient := TIdHTTP.Create(nil);
ioHnd := TIdSSLIOHandlerSocketOpenSSL.Create(nil);
ioHnd.DefaultPort := iSSL_PORT;
ioHnd.SSLOptions.Mode := sslmClient;
idHTTPClient.IOHandler := ioHnd;
idHTTPClient.Request.AcceptEncoding := 'gzip,deflate,identity';
idHTTPClient.Request.BasicAuthentication := False;
try
idHTTPClient.Post(FFQDN, stmRequest, stmResponse);
except
on E:Exception do
begin
if IdSSLOpenSSLHeaders.WhichFailedToLoad <> '' then
begin
AddMsg('Failed to load file ' + IdSSLOpenSSLHeaders.WhichFailedToLoad + '. ' + E.Message);
end;
end;
end;
There are three versions of the ssleay32 and libeay32.dll files on the machine. One set is in the same folder as my executable (V1.0.0.5). One set is in the Apache bin folder (V0.9.8.20) and one set is in C:\Windows\SysWOW64 (no version but dated 2003).
When the app starts it runs fine. But after a few days the Post call starts to fail with "Could not load SSL library". The files which fail to load are:
SSL_SESSION_get_id,SSL_COMP_get_compression_methods
Once this problem starts to happen it won't go away until the app is restarted. Then it works fine again for another few days.
It would seem to me that for some reason the dlls being loaded change after a few days. How could this happen and what could I do to ensure the correct files are loaded every time?
Ideally, delete all the other versions of OpenSSL DLLs on your machine to ensure that your app always finds the correct DLL. Its the multiple versions and processes (Apache) loading these different versions that is causing the conflict.

Delphi with indy

I just started using indy10 (today) in Delphi 2010, after reading everywere i managed to make it work, i can send emails using gmail, it works fine on my computer, but when i install the application on my laptop (for tests), it doesnt send the email and my app stops working, do i have to install something else on my laptop or how can i make it to work on every computer i install my program, so far i have to install it on 6 different computers, some use windows XP and some Windows 7, i hope there is a way to make it multiplatform or something.
This is my code:
procedure SendIndyMail;
begin
Form_final.IdSMTP1 .IOHandler := Form_final.IdSSLIOHandlerSocketOpenSSL1;
Form_final.IdSMTP1.Host:= 'smtp.gmail.com';
Form_final.IdSMTP1.Password:= 'xxxxxx';
Form_final.IdSMTP1.Port := 587;
Form_final.IdSMTP1.UseTLS := utUseExplicitTLS;
Form_final.IdSMTP1.Username := 'xxxxxx';
Form_final.IdSSLIOHandlerSocketOpenSSL1.Destination := 'smtp.gmail.com:587';
Form_final.IdSSLIOHandlerSocketOpenSSL1.Host := 'smtp.gmail.com';
Form_final.IdSSLIOHandlerSocketOpenSSL1.Port := 587;
Form_final.IdSSLIOHandlerSocketOpenSSL1.SSLOptions.Method := sslvTLSv1;
Form_final.IdSSLIOHandlerSocketOpenSSL1.SSLOptions.Mode := sslmUnassigned;
Form_final.IdSSLIOHandlerSocketOpenSSL1.SSLOptions.VerifyMode := [];
Form_final.IdSSLIOHandlerSocketOpenSSL1.SSLOptions.VerifyDepth := 0;
Form_final.IdMessage1.Subject:=conect.Q_selec_info_generalDescripcion.Text+' '+DateToStr(Date);
Form_final.IdMessage1.Recipients.EMailAddresses:=conect.Q_config_seleccorreo.Text;
TIdAttachmentFile.Create(Form_final.IdMessage1.MessageParts, conect.Q_config_selecfolder.Text+'\reporte_'+FormatDateTime('dddd d of mmmm yyyy', Date)+' Inventario '+Form_inventario.Edit_id_inventario.Text+'.pdf');
Form_final.IdSMTP1.Connect;
Form_final.IdSMTP1.Send(Form_final.IdMessage1);
Form_final.IdSMTP1.Disconnect;
end;
I ran the proyect on my laptop and it says:
Could not load SSL Library, now, i did many things to make it work, downloaded many things and tried many other, now i dont know where those libraries are and how to retrieve them, and i would like to know of a way to load them with the installation so my installer goes with everything needed.
Thanks in advance.
Make sure you have the OpenSSL DLLs on your target machines, preferrably in your app's installation folder. If you still get the error, Indy's WhichFailedToLoad() function in the IdSSLOpenSSLHeaders unit can tell you why it could not load the OpenSSL DLLs. As for the DLLs themselves, you can download Indy-compatible copies from Indy's Fulgan mirror.
On a side note, you do not need to set the IOHandler's Destination, Host, or Port properties. The Connect() method will handle that internally for you.

How to connect in a firebird database in execution time?

I'm having a hard time to make my code work. I want to connect to a database with my application in Delphi 7, but if I change the folder of the application, for example, if I install in another computer, my datamodule stops working. The error is:
Raised exception class EdatabaseError with message "Missing Drivername propriety"
My actual code is:
procedure TDataModule1.DataModuleCreate(Sender: TObject);
var
conexao : TSQLConnection;
begin
with SQLConnection1 do
begin
ConnectionName := 'SKY';
DriverName := 'Interbase';
LibraryName := 'dbexpint.dll';
VendorLib := 'gds32.dll';
GetDriverFunc := 'getSQLDriverINTERBASE';
LoadParamsOnConnect := true;
LoginPrompt := False;
Params.Add('Database='+ExtractFilePath(Application.ExeName)+'\Banco\FLY_SKY_DESK.FDB');
Params.Add('User_Name=SYSDBA');
params.Add('Password=masterkey');
Params.Add('SQLDialect=3');
Open;
end;
SQLConnection1.Connected:=true;
end;
I want to connect to the database using my .exe, on any path or install location.
If you are running Windows 7 or Vista, and install your app into the "\Program files" (either one) directory, this will not work due to folder virtualization within UAC.
You should NOT attempt to place the database within the same directory that the program is running from. You will get away with it on XP and earlier. From then on, it's a no-no.
This may not be your problem, but it definitely IS a problem.
I faced a similar problem when I tried to write code which would open a Firebird database from a thread. The code looks like you are using the dbExpress TSQLConnection; it's much easier if you use the IB components, specifically TIBDatabase. Then your code becomes something like the following
var
ibdb: TIBDatabase;
qDefaults: TIBQuery;
trans: TIBTransaction;
begin
ibdb:= TIBDatabase.Create (nil);
ibdb.databasename:= ExtractFilePath(Application.ExeName)+'\Banco\FLY_SKY_DESK.FDB')
ibdb.loginprompt:= false;
ibdb.params.add ('password=masterkey');
ibdb.params.add ('user_name=sysdba');
ibdb.sqldialect:= 3;
ibdb.connected:= true;
trans:= TIBTransaction.create (nil);
trans.defaultdatabase:= ibdb;
qDefaults:= TIBQuery.create (nil);
qDefaults.database:= ibdb;
qDefaults.transaction:= trans;
qDefaults.sql.Add ('select * from defaults');
qDefaults.active:= true;
...
You are most likely missing the DLLs required on the target computer. You'll need to figure out which DLLs should be included with the client application and install them on the target computer. Often, simply placing the required DLLs in the same folder as the EXE will work.
I can't figure out quite what you're using since you reference Interbase and dbExpress and Firebird, but your target computer probably doesn't have the needed drivers.
You need to deploy:
dbxconnections.ini
dbxdrivers.ini
dbxfb.dll
fbclient.dll
midas.dll {in case you used ClientDatasSet and you didn't include MidasLib into uses clause}
after deploy all those files along with your Exe than you need to update registry entry to point to locations of dbxconnections.ini and dbxdrivers.ini my version is delphi 10.3 so the registry entry are located in
HKEY_CURRENT_USER > Software > Embarcadero > BDS > 20.0 > DBExpress
Connection Registry File value is the path to dbxconnections.ini
Driver Registry File value is the path to dbxdrivers.ini

Delphi 2010: Firebird dbExpress Error Unable to load dbxfb4d14.dll

I just downloaded the dbExpress Driver for Firebird by Chee-Yang Chau from this google code site.
I loaded the Delphi 2010 demo projects and tried running it and immediatedly got a could not load dll error:
INI File
[Installed Drivers]
FirebirdConnection=1
[FirebirdConnection]
;DriverUnit=DBXInterBase
;DriverPackageLoader=TDBXDynalinkDriverLoader,DbxCommonDriver120.bpl
;DriverAssemblyLoader=Borland.Data.TDBXDynalinkDriverLoader,Borland.Data.DbxCommonDriver,Version=12.0.0.0,Culture=neutral,PublicKeyToken=91d62ebb5b0d1b1b
;MetaDataPackageLoader=TDBXInterbaseMetaDataCommandFactory,DbxInterBaseDriver120.bpl
;MetaDataAssemblyLoader=Borland.Data.TDBXInterbaseMetaDataCommandFactory,Borland.Data.DbxInterBaseDriver,Version=12.0.0.0,Culture=neutral,PublicKeyToken=91d62ebb5b0d1b1b
GetDriverFunc=getSQLDriverFIREBIRD
LibraryName=dbxfb4d14.dll
VendorLib=C:\Program Files\Firebird\Firebird_1_5\bin\fbclient.dll
BlobSize=-1
CommitRetain=False
Database=database.gdb
ErrorResourceFile=
LocaleCode=0000
Password=masterkey
RoleName=RoleName
ServerCharSet=
SQLDialect=3
Interbase TransIsolation=ReadCommited
User_Name=sysdba
WaitOnLocks=True
Trim Char=False
Delphi Code
procedure TMainForm.Button1Click(Sender: TObject);
var C: TSQLConnection;
begin
C := TSQLConnection.Create(Self);
try
C.DriverName := 'FirebirdConnection';
// C.LibraryName := 'dbxufb40.dll';
// C.VendorLib := 'C:\Program Files\Firebird\Firebird_1_5\bin\fbclient.dll';
// C.GetDriverFunc := 'getSQLDriverFIREBIRD';
C.Params.Add('User_Name=SYSDBA');
C.Params.Add('Password=masterkey');
C.Params.Add('Database=localhost:%ProgramFiles%\Firebird\Firebird_1_5\examples\employee.fdb');
C.Open;
if C.Connected then
ShowMessage('Connection is active')
finally
C.Free;
end;
end;
I noticed that the library name dbxfb4d14.dll in the ini file did not match the actual dll name dbxfb4d15.dll so I modified the ini file so it would match the name of the dll.
Now I get an error saying the dbxfb4d15.dll cannot be found.
What am I doing wrong?
You do need the d14 version for Delphi 2010. The d15 version is for XE. Not sure why there is only the d15 version in the zip.
The DLL is not located on your DLL search path. Once you get hold of the right DLL then you need to make sure it's on the path.
Having browsed around this component I'm not convinced it's terribly polished. If you can afford it, the Devart drivers come highly recommended.

Resources