TFPHTTPClient throws "Could not initialize OpenSSL library" error lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- fedkad · 2022-10-24 12:45 I have the following simple test program: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit Unit1; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls  , fphttpclient, opensslsockets; type   { TForm1 }   TForm1 = class(TForm)    Button1: TButton;    Label1: TLabel;    procedure Button1Click(Sender: TObject);  private   public   end; var  Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.Button1Click(Sender: TObject);const  check_url = 'https://www.example.com/';var  cl : TFPHTTPClient;begin  Label1.Caption := 'Accessing '+check_url;  Application.ProcessMessages;  cl := TFPHTTPClient.Create(Form1);  try    cl.AllowRedirect := True;    Label1.Caption := cl.Get(check_url);  except    on E: Exception do      MessageDlg ('Error accessing ' + check_url + LineEnding + E.ClassName + ':'        + LineEnding + E.Message,        mtError, [mbOK], 0);  end;  cl.Free;end; end. This code works perfectly on Ubuntu 22.04: It accesses the page at https://www.example.com/ and displays its raw HTML contents. However, the same program gives the error: Error accessing https://www.example.com/ EInOutError: Could not initialize OpenSSL library on Ubuntu 22.10. Note: The same problem is present on Windows 11. I remember a similar code working as expected on Windows 10, but currently I do not have a Windows 10 installation to test. It is working OK on Windows XP (32-bit compilation). Please, note that the problem is not related to compilation environment. By, copying the executable from system to system, I can confirm that the same executable works correctly on Ubuntu 22.04, but not on 22.10. So, the problem is obviously related to the run-time environment. The same problem occurs on the sample programs given at: https://wiki.lazarus.freepascal.org/fphttpclient Lazarus is at its latest version 2.2.4. Update: * I have read similar threads in this forum, but they didn't help. I am in a pure 64-bit environment. OS and Lazarus applications are all 64-bit. I remember that the program was running OK in my test system while it was on Ubuntu 22.04, but not after the upgrade to 22.10. * Comparing the differences between the two versions of Ubuntu (22.04 vs 22.10) I noticed that the package libssl1.1/now 1.1.1l-1ubuntu1.2 amd64 is no longer available for Ubuntu 22.10 and it was removed.  So, running the commands: Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i # wget http ://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f- 1ubuntu2_amd64.deb# apt install ./libssl1.1_1.1.1f-1ubuntu2_amd64.deb fixes the problem. But, obviously, this is not something I would like to do. What are my options? ---------------------------------------------------------------------- ruewa · 2022-11-02 22:55 Not sure whether it's the same problem, but I had the same  error on Ubuntu 22.04. Installing libssl-dev solved it. ---------------------------------------------------------------------- Jurassic Pork · 2022-11-02 23:31 hello, when you have this kind of problem, look at the file openssl.pas in the folder fpcsrc\packages\openssl\src. At the beginning of the file, you can see something like this : Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i var  {$IFDEF WINDOWS}  DLLSSLName: string = 'ssleay32.dll';  DLLSSLName2: string = 'libssl32.dll';  DLLUtilName: string = 'libeay32.dll';  {$ELSE}   {$IFDEF OS2}    {$IFDEF OS2GCC}  DLLSSLName: string = 'kssl10.dll';  DLLUtilName: string = 'kcrypt10.dll';  DLLSSLName2: string = 'kssl.dll';  DLLUtilName2: string = 'kcrypto.dll';    {$ELSE OS2GCC}  DLLSSLName: string = 'emssl10.dll';  DLLUtilName: string = 'emcrpt10.dll';  DLLSSLName2: string = 'ssl.dll';  DLLUtilName2: string = 'crypto.dll';    {$ENDIF OS2GCC}   {$ELSE OS2}  DLLSSLName: string = 'libssl';  DLLUtilName: string = 'libcrypto';   { ADD NEW ONES WHEN THEY APPEAR!    Always make .so/dylib first, then versions, in descending order!    Add "." .before the version, first is always just "" }  DLLVersions: array[1..17] of string = ('', '.1.1', '.1.0.6', '.1.0.5', '.1.0.4', '.1.0.3',                                      '.1.0.2', '.1.0.1','.1.0.0','.0.9.8',                                      '.0.9.7', '.0.9.6', '.0.9.5', '.0.9.4',                                      '.0.9.3', '.0.9.2', '.0.9.1');   {$ENDIF OS2}  {$ENDIF WINDOWS} As you can see the last version of libssl and libcrypto that you can use is the 1.1 for linux To see what are the crypto libraries installed on your linux O.S, in a terminal launch this : Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i ldconfig -p | grep cryptoldconfig -p | grep ssl  on my Ubuntu 20.04 : Quoteubuntu$ldconfig -p | grep ssl libwolfssl.so.24 (libc6,x86-64) => /lib/x86_64-linux- gnu/libwolfssl.so.24 libssl3.so (libc6,x86-64) => /lib/x86_64-linux-gnu/libssl3.so libssl.so.1.1 (libc6,x86-64) => /lib/x86_64-linux-gnu/libssl.so.1.1 ubuntu$ldconfig -p | grep crypto libmbedcrypto.so.3 (libc6,x86-64) => /lib/x86_64-linux- gnu/libmbedcrypto.so.3 libk5crypto.so.3 (libc6,x86-64) => /lib/x86_64-linux- gnu/libk5crypto.so.3 libhcrypto.so.4 (libc6,x86-64) => /lib/x86_64-linux- gnu/libhcrypto.so.4 libcrypto.so.1.1 (libc6,x86-64) => /lib/x86_64-linux- gnu/libcrypto.so.1.1 libbd_crypto.so.2 (libc6,x86-64) => /lib/x86_64-linux- gnu/libbd_crypto.so.2 version 1.1 is installed. Friendly, J.P ---------------------------------------------------------------------- fedkad · 2022-11-03 10:38 Quote from: Jurassic Pork on November 03, 2022, 12:31:36 amversion 1.1 is installed. Thanks J.P. for the reply. The problem is that "libssl1.1" is no longer provided in newer versions of Ubuntu. Instead we have only "libssl3". I think FreePascal should be updated for this. ---------------------------------------------------------------------- Jurassic Pork · 2022-11-03 11:37 Hello, Quote from: fedkad on November 03, 2022, 11:38:45 amThanks J.P. for the reply. The problem is that "libssl1.1" is not longer provided in newer versions of Ubuntu. Instead we have only "libssl3". the last version of openssl.pas manages  this library but it is only in the fpc trunk ( i think not yet out in a release version of fpc) Quote21 Apr, 2022 1 commit Add support for OpenSSL 3.0 Bi0T1N authored 6 months ago and Michael Van Canneyt's avatar Michael Van Canneyt committed 6 months ago Friendly, J.P ---------------------------------------------------------------------- fedkad · 2022-11-03 12:27 Quote from: Jurassic Pork on November 03, 2022, 12:37:36 pm the last version of openssl.pas manages  this library but it is only in the fpc trunk ( i think not yet out in a release version of fpc) Quote21 Apr, 2022 1 commit Add support for OpenSSL 3.0 Bi0T1N authored 6 months ago and Michael Van Canneyt's avatar Michael Van Canneyt committed 6 months ago Thanks for the info! ---------------------------------------------------------------------- prof7bit · 2022-11-17 13:56 In my application I am doing something like this to make it run on current Ubuntu without being forced to use fpc trunk. This seems to work for now. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i         {$ifndef windows}        if not InitSSLInterface then begin          Debug('ssl version 1.x not found, trying version 3');          openssl.DLLVersions[1] := '.3';        end;        {$endif}        if not InitSSLInterface then begin          Debug('ssl not supported');        exit(mqeSSLNotSupported);        end; ---------------------------------------------------------------------- PizzaProgram · 2025-12-27 08:41 (I know this topic is mostly for *nix OS, and only mentioning Windows, but it's the first finding of DuckDuckGo, so I post it here...) I've just tried using TFPHTTPClient under latest: Lazarus 4.4 (FPC 3.2.2) 32bit app, OS = WinServer2016 (=Win10 based) Downloaded latest SSL binaries + installed both: 32 + 64 from recommended site: https://slproweb.com/products/Win32OpenSSL.html Same error message. Looking at the openssl.pas unit, I do not see any SSL3 initialisation / filenames at all! The 7 year old SSL v1.1.1w ended 2+ years ago!  https://endoflife.date/openssl IMHO there are 3 problems: 1. The official wiki needs a big bold red-coloured warning, that it does not support current (Recommended) SSL versions at the top: https://wiki.lazarus.freepascal.org/fphttpclient 2. The official SSL binaries do not include v1.1 any more. (For obvious reason)  Checked this one too: https://kb.firedaemon.com/support/solutions/art icles/4000121705-openssl-binary-distributions-for-microsoft-windows -> So a direct link to the last version of binaries of 1.1.1 should be on the Wiki too, if somebody still wants to use the old ones with this source. 3. Either a new version of TFPHTTPClient.pas + openssl.pas should be included in Lazarus install, which does support SSL3.5+, or drop a recommendation to the wiki page for best preferred alternative. Either way, the current Wiki + PAS files are not working under Windows! Thanks! ---------------------------------------------------------------------- PizzaProgram · 2025-12-27 08:56 PS: Latest trunc of Ararat Synaps does support SSL3 fine since years! https://sourceforge.net/p/synalist/code/HEAD/tree/trunk/ ( Reported it 3+ years ago: https://forum.lazarus.freepascal.org/inde x.php/topic,48677.msg441043.html#msg441043 ) Why is not the latest source included in Lazarus/FPC ? ---------------------------------------------------------------------- paweld · 2025-12-27 09:04 Version 3.2.2 does not support OpenSSL3, but version 3.2-fixes and the upcoming 3.2.4 (currently RC1) already support OpenSSL3. You can also use the following components: - synapse: https://github.com/geby/synapse - indy ( https://github.com/IndySockets/Indy ) + IndySecOpenSSL ( https://github.com/MWASoftware/IndySecOpenSSL ) - mormot2: https://github.com/synopse/mORMot2 All these components are also available in OPM. ---------------------------------------------------------------------- dsiders · 2025-12-27 09:06 Quote from: PizzaProgram on December 27, 2025, 09:41:28 am(I know this topic is mostly for *nix OS, and only mentioning Windows, but it's the first finding of DuckDuckGo, so I post it here...) I've just tried using TFPHTTPClient under latest: Lazarus 4.4 (FPC 3.2.2) 32bit app, OS = WinServer2016 (=Win10 based) Downloaded latest SSL binaries + installed both: 32 + 64 from recommended site: https://slproweb.com/products/Win32OpenSSL.html Same error message. Looking at the openssl.pas unit, I do not see any SSL3 initialisation / filenames at all! What leads you to believe that FPC 3.2.2 supports SSL 3.X? ---------------------------------------------------------------------- Thaddy · 2025-12-27 09:42 Yes. Also all this has been answered so many times everybody lost count.... If you definitely want to stick to 3.2.2 there is also the option to just checkout the openssl bindings from the fixes branch or trunk, since the bindings do not contain new language features.