7

In my application I am using IdHTTP.Get. A part of the code:

var
  IdHTTP: TIdHTTP;
begin
  IdHTTP := TIdHTTP.Create(nil);
  Output := IdHTTP.Get(url);
  ...
  IdHTTP.Free;

Using IdHTTP.Version gives me the version: 10.6.2.5263

I have downloaded the OpenSSL from here, both libeay32.dll and ssleay32.dll are in the same folder of my application.

This problem occured since I am using a new laptop with Windows 10. I hope someone can tell me how to solve this problem!

Teun
  • 579
  • 1
  • 7
  • 14
  • 3
    Use Indy's `WhichFailedToLoad()` function in the `IdSSLOpenSSLHeaders `unit to find out which DLL failed to load. – whosrdaddy Feb 09 '16 at 14:28
  • 1
    Check the firewall settings for (application-specific) block of outgoing connections – mjn Feb 09 '16 at 14:58
  • 1
    @whosrdaddy thanks, it appears that only libeay32.dll failed to load – Teun Feb 09 '16 at 15:39
  • 1
    @mjn I turned off the firewall and tried, but it didn't help – Teun Feb 09 '16 at 15:41
  • 2
    @Teun: what *exactly* is `WhichFailedToLoad()` returning? – Remy Lebeau Feb 09 '16 at 16:06
  • 1
    @RemyLebeau: "Failed to load libeay32.dll." – Teun Feb 10 '16 at 07:51
  • 1
    That means either libeay32.dll could not be found, or it could not be loaded into memory by `SafeLoadLibrary()`. – Remy Lebeau Feb 10 '16 at 16:23
  • 1
    @RemyLebeau: libeay32.dll is in the same folder as ssleay32.dll so I guess it can be found. What can cause the not loading into memory by SafeLoadLibrary()? – Teun Feb 10 '16 at 19:56
  • 1
    @Teun: By default, Indy loads the OpenSSL DLLs using relative paths, so Windows' [DLL Search Order](https://msdn.microsoft.com/en-us/library/windows/desktop/ms682586.aspx) takes affect. If needed, Indy does have an `IdOpenSSLSetLibPath()` function to specify a specific folder instead. Either way, to find out why `SafeLoadLibrary()` is failing, you would have to call it directly and then see what `GetLastError()` reports. – Remy Lebeau Feb 11 '16 at 01:50
  • 1
    I managed to solve the problem. I have removed the earlier downloaded OpenSSL and downloaded the OpenSSL from this site: http://external.informer.com/slproweb.com/ there I downloaded and installed Win32 OpenSSL v1.0.2f Light and that appears to have solved my problem – Teun Feb 11 '16 at 11:30

3 Answers3

2

If you need to access an https url, you must add some code, to complete the creation of the TidHTTP component.

Try use something like this:

// create components
HTTPs := Tidhttp.Create(nil);
IdSSL := TIdSSLIOHandlerSocket.Create(nil);
// try..finally for free
try
  // ini
  HTTPs.ReadTimeout := 30000;
  HTTPs.IOHandler := IdSSL;
  IdSSL.SSLOptions.Method := sslvTLSv1;
  IdSSL.SSLOptions.Method := sslvTLSv1;
  IdSSL.SSLOptions.Mode := sslmUnassigned;
  ...

You need to add IdSSLOpenSSL to uses clause.

Toon Krijthe
  • 52,876
  • 38
  • 145
  • 202
0

Having 32 bit target platform for your application in a 64 bit system will also cause this problem. I don't know how to properly fix this but an easy way is to compile exe for same system your OS is.

Doege
  • 341
  • 4
  • 12
0

After trying the various solutions offered here, none of them work with the latest version of Windows 10 or Windows 11. I would like to share my solution that works:

Just install the latest version of open SSL openssl-1.0.2u-x64_86-win64 which is available here.

It includes the two necessary libraries for TidHTTP libeay32.dll and ssleay32.dll in version 1.0.2.21

tomerpacific
  • 4,704
  • 13
  • 34
  • 52
franckcl
  • 1
  • 1
  • I tried your solution but it was not work for me. I have downloaded and copied these are two files into my application directory but my program send the same error message than your meessage. "Could not load SSL library." Do you have any idea about this issue? – Lionking Oct 24 '22 at 10:50
  • FYI, the official place to get the DLLs nowadays is from Indy's GitHub repo: https://github.com/IndySockets/OpenSSL-Binaries That said, use Indy's `WhichFailedToLoad()` function to tell you WHY the DLLs failed to load. – Remy Lebeau May 10 '23 at 01:16