I have the following simple test program:
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/fphttpclientLazarus 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:
# 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?