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