Forum > Other

[SOLVED] FreeBSD 12.0 - TFPHttpClient -OpenSSL- Access violation



--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function GetWebPage(const aURL: string): string;var  Client: TFPHttpClient;begin  Client := TFPHttpClient.Create(nil);   Try    Client.AllowRedirect := true;    Client.AddHeader('User-Agent', 'Mozilla/5.0(compatible; fpweb)');    Result := Client.Get(aURL);  except      on E: Exception do           ShowMessage('Retrieval of: ' + aURL + LineEnding                    + 'Failed with error: ' + E.Message + LineEnding                    + 'HTTP code: ' + IntToSTr(Client.ResponseStatusCode));  end;end; 
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: ---trev@macfbsd [/home/trev] $ ldconfig -r | grep '[st][ls][ls]'
        103:-lssl.111 => /usr/lib/
        394:-lgnutlsxx.28 => /usr/local/lib/
        397:-lgnutls.30 => /usr/local/lib/
        419:-levent_openssl-2.1.6 => /usr/local/lib/
        540:-lssl.5 => /usr/local/lib/compat/
trev@macfbsd [/home/trev] $ ldconfig -r | grep crypto
        39:-lcrypto.111 => /lib/
        477:-lcrypto.5 => /usr/local/lib/compat/

--- End code ---

And I have the FPC openssl unit installed:

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

--- End code ---

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.)

It's probably related to this nasty bug:

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

Thanks rsz, I'll give it a go and see what happens.

Yes! Updating to FPC 3.3.1 and adding the OpenSSLSockets unit to the project was the solution. Thanks again rsz.


[0] Message Index

Go to full version