Recent

Author Topic: [SOLVED] FreeBSD 12.0 - TFPHttpClient -OpenSSL- Access violation  (Read 2593 times)

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Code: Pascal  [Select][+][-]
  1. function GetWebPage(const aURL: string): string;
  2. var
  3.   Client: TFPHttpClient;
  4. begin
  5.   Client := TFPHttpClient.Create(nil);
  6.  
  7.   Try
  8.     Client.AllowRedirect := true;
  9.     Client.AddHeader('User-Agent', 'Mozilla/5.0(compatible; fpweb)');
  10.     Result := Client.Get(aURL);
  11.   except
  12.       on E: Exception do
  13.            ShowMessage('Retrieval of: ' + aURL + LineEnding
  14.                     + 'Failed with error: ' + E.Message + LineEnding
  15.                     + 'HTTP code: ' + IntToSTr(Client.ResponseStatusCode));
  16.   end;
  17. end;
  18.  

The above code results in the attached 'Access Violatioin' error dialog.

After much hair pulling I can no longer afford, I tracked the cause down to trying to make an HTTPS connection. HTTP connections work without error.

Yes, I have openssl installed (it's part of the FreeBSD 'base' code):

Code: [Select]
trev@macfbsd [/home/trev] $ ldconfig -r | grep '[st][ls][ls]'
        103:-lssl.111 => /usr/lib/libssl.so.111
        394:-lgnutlsxx.28 => /usr/local/lib/libgnutlsxx.so.28
        397:-lgnutls.30 => /usr/local/lib/libgnutls.so.30
        419:-levent_openssl-2.1.6 => /usr/local/lib/libevent_openssl-2.1.so.6
        540:-lssl.5 => /usr/local/lib/compat/libssl.so.5
trev@macfbsd [/home/trev] $ ldconfig -r | grep crypto
        39:-lcrypto.111 => /lib/libcrypto.so.111
        477:-lcrypto.5 => /usr/local/lib/compat/libcrypto.so.5

And I have the FPC openssl unit installed:

Code: [Select]
trev@macfbsd [/home/trev] $ pkg info | grep -i openssl
fpc-openssl-3.0.4              Free Pascal unit for OpenSSL

FPC 3.04; Lazarus 2.0 (from FreeBSD ports).

Any ideas why Lazarus/FPC cannot seem to find the openssl libraries which I'm assuming from my research is the underlying issue? (The same code works for macOS.)
« Last Edit: July 18, 2019, 03:48:27 am by trev »

rsz

  • New Member
  • *
  • Posts: 45
Re: FreeBSD 12.0 - TFPHttpClient -OpenSSL- Access violation
« Reply #1 on: July 02, 2019, 12:39:12 pm »
It's probably related to this nasty bug: https://bugs.freepascal.org/view.php?id=32789

I can't say for FreeBSD, but building and installing the latest FPC and Lazarus solved the issue for me on Ubuntu 19.04.

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: FreeBSD 12.0 - TFPHttpClient -OpenSSL- Access violation
« Reply #2 on: July 02, 2019, 12:48:08 pm »
Thanks rsz, I'll give it a go and see what happens.

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: [SOLVED] FreeBSD 12.0 - TFPHttpClient -OpenSSL- Access violation
« Reply #3 on: July 18, 2019, 03:49:39 am »
Yes! Updating to FPC 3.3.1 and adding the OpenSSLSockets unit to the project was the solution. Thanks again rsz.

 

TinyPortal © 2005-2018