ondertol
ondertol

Reputation: 67

Could not load SSL library - dll not found

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?

Upvotes: 2

Views: 7490

Answers (1)

Remy Lebeau
Remy Lebeau

Reputation: 598134

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.

Upvotes: 4

Related Questions