Bookstore

Recent

Author Topic: fphttpclient https/tls on Linux Mint 19.3 (base Ubuntu 18.04)  (Read 595 times)

Xelandre

  • Newbie
  • Posts: 1
fphttpclient https/tls on Linux Mint 19.3 (base Ubuntu 18.04)
« on: January 31, 2020, 08:22:03 pm »
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:

Code: Pascal  [Select]
  1. {$mode delphi}
  2. uses
  3.     classes,
  4.     sysutils,
  5.     strutils,
  6.     fileutil,
  7.     fpopenssl,
  8.     openssl,
  9.     sslsockets,
  10.     ssockets,
  11.     fphttpclient;
  12.  
  13. var cli: TFPHTTPClient;
  14.     s,url: string;
  15. const useragent = 'Mozilla/5.0 (compatible; fpweb)';
  16. begin
  17.    InitSSLInterface;
  18.    url:='https://forum.lazarus.freepascal.org/';
  19.    cli := TFPHTTPClient.Create(nil);
  20.    try
  21.       s:=cli.get(url);
  22.       cli.AddHeader('User-Agent',useragent);
  23.       cli.AllowRedirect := true;
  24.    except
  25.       writeln(erroutput,'Ouch!');
  26.    end;
  27.    
  28.    writeln(length(s));
  29.    writeln(s);
  30.  
  31.    cli.free;  
  32. end.
  33.  

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!
« Last Edit: January 31, 2020, 08:35:50 pm by Xelandre »