Lazarus, Linux, Indy 10 and OpenSSL error

Veröffentlicht von

Using the IdHTTP component to access https websites, returned an error: „Could not load SSL library2“.

On Linux, I tried to use Lazarus with the Indy 10 components. I wanted to use the „IdHttp“ component to access and download something from the internet. The code is quite simple:

html:= IdHTTP1.Get('https://ekiwi.de');

Howewer I got an error, that the SSL library could not be found.

EIOSSLCouldNotLoadSSLLibrary
Could not load SSL library.
In file 'IdSSLOpenSSL.PAS'

Searching the internet, the problem is, that the library is either missing or installed in the wrong version. Indy 10 still needs the version 1.0.2.

For Windows, it should be enough to place the DLLs in the program folder. You can find binary releases here.

On Linux, I compiled the version, with the following set of commands:

wget https://www.openssl.org/source/old/1.0.2/openssl-1.0.2u.tar.gz
tar -xf openssl-1.0.2u.tar.gz
cd openssl-1.0.2u
./config shared
make

After that, I copied the library files over to the program folder.

cp *.so /path/to/copy/to

However is is not enough for Linux, as the program does not look there by default.

So I needed to point the Indy components to the correct folder:

IdOpenSSLSetLibPath(path);

The complete example code:

unit IdSSLOpenSSLHeaders

procedure TForm1.Button1Click(Sender: TObject);
var html, path:string;
begin
  path:= ExtractFilePath(Application.ExeName);
  ShowMessage(path);
  IdOpenSSLSetLibPath(path);

  html:= IdHTTP1.Get('https://ekiwi.de');
  Memo1.Text:= html;
end; 

After that the download worked.

Kommentar hinterlassen

Deine E-Mail-Adresse wird nicht veröffentlicht.