Hello,
I'm trying to get a bunch of code compiled in 3.0.4 from an earlier Linux version to work on a machine with a fresh Linux Mint 19.3 installation, which is based on Ubuntu 18.04.
My problem is that fphttpclient get(url) fails on https URLs. As plain http links do work correctly, my immediate supposition was a problem in TLS/SSL library versions. I dug into the FCL source code and the system libraries for a couple of hours, alas without much success.
This is the test code snippet:
{$mode delphi}
uses
classes,
sysutils,
strutils,
fileutil,
fpopenssl,
openssl,
sslsockets,
ssockets,
fphttpclient;
var cli: TFPHTTPClient;
s,url: string;
const useragent = 'Mozilla/5.0 (compatible; fpweb)';
begin
InitSSLInterface;
url:='https://forum.lazarus.freepascal.org/';
cli := TFPHTTPClient.Create(nil);
try
s:=cli.get(url);
cli.AddHeader('User-Agent',useragent);
cli.AllowRedirect := true;
except
writeln(erroutput,'Ouch!');
end;
writeln(length(s));
writeln(s);
cli.free;
end.
Looking at other threads, it seems that I'm experiencing a known problem in 3.0.4, e.g. here:
https://forum.lazarus.freepascal.org/index.php/topic,46560.0.html , and I persist in thinking that the issue lies in the interface to TLS.
At this point, I see the following alternatives, in decreasing order of preference:
3) Upgrade to fpc 3.2 (The preceding thread suggests that it solves this issue)
2) Rewrite a skeleton fphttpclient based on libcurl.
1) Downgrading the installed TLS to an earlier version (as suggested in earlier threads), but I have no real guarantee that this would solve the problem.
Does any one have any other ideas? I'm hoping for a patch to the FCL library. Or am I barking up the wrong tree?
Where/how can I get 3.2, or parts thereof? I can't access that directory under
ftp://ftp.freepascal.org/fpc/beta/ .
Rewriting a barebones fphttpclient would probably require a couple of hours (I have a libcurl code base I can reuse). But I would gladly reuse someone else's code, if some exists.
Thanks!