Use "TSSLSocketHandler.GetDefaultHandler" to create an SSL handler with the default handler class. To register the default handler class to be OpenSSL simply import the "opensslsockets" unit in your uses clause and you should be fine
uses
ssockets, sslsockets, opensslsockets;
...
FSocket := TInetSocket.Create(Host, Port, TSSLSocketHandler.GetDefaultHandler);
Thank you.
Unfortunatley this does not seem to work. If I run that code (with FPC latest main) I get this exception:
An unhandled exception occurred at $00000000004AE9E1:
EAccessViolation: Access violation
$00000000004AE9E1 Write, line 624 of openssl/src/fpopenssl.pp
$0000000000460A18 WriteByte, line 1221 of ../objpas/classes/streams.inc
If I single step into it I notice that in
opensslsockets.pp, line 304,
in method TOpenSSLSocketHandler.Send
in that line:
Result:=FSsl.Write(@Buffer,Count);
FSsl is nil!
So there seems to be some initialization missing or broken.
I am using Ubuntu 22.04.1 LTS and I have libssl.so.3 (which is why I need FPC trunk)
Does the following minimal test program run on our system?
program test1;
uses
ssockets, sslsockets, opensslsockets;
var
FSocket: TInetSocket;
begin
FSocket := TInetSocket.Create('google.com', 443, TSSLSocketHandler.GetDefaultHandler);
FSocket.WriteByte(0);
FSocket.Free;
end.