I am using TIdHTTP
to get from a https URL, my code works fine until http is used, but on https i have
Socket Error # 10054 Connection reset by peer.
In many SO answers I Read about TLS 1.0 being the default so I tried to set it to TLS 1.2
I experimented by changing many properties in TIdHTTP
and TIdSSLIOHandlerSocketOpenSSL
but with no success.
The URL against which this fails is https://nesufficio.my.qualibus.it/FeriePermessiDemo/DOQualibus/QappCommandHandler
.
There is an handshake issue I am not able to overcome, if I disable the firewall and proxy and connect to the http URL directly it works (even if in that case I must use the full URL to have a meaningful behavior). So my problem is purely in Indy: how to connect to that URL successfully?
This is the code i use:
procedure TForm1.btnGetFromMyWebserver(Sender: TObject);
var
IdHTTP: TIdHTTP;
IdSSLIOHandlerSocketOpenSSL: TIdSSLIOHandlerSocketOpenSSL;
response, url: string;
begin
IdHTTP := TIdHTTP.Create;
// here i set the custom headers that are not relevant
// to study the connection closed by peer problem
try
try
IdSSLIOHandlerSocketOpenSSL := TIdSSLIOHandlerSocketOpenSSL.Create(IdHTTP);
IdSSLIOHandlerSocketOpenSSL.Port := 443; // I tried to force the port to 443
IdSSLIOHandlerSocketOpenSSL.SSLOptions.Mode := sslmClient;
IdSSLIOHandlerSocketOpenSSL.SSLOptions.SSLVersions:= [sslvTLSv1_2];
IdHTTP.IOHandler := IdSSLIOHandlerSocketOpenSSL;
IdHTTP.HandleRedirects := True;
url := 'https://nesufficio.my.qualibus.it/FeriePermessiDemo/DOQualibus/QappCommandHandler'; // this is not the actual endpoint but it is enough to reproduce the handshaking error
response := IdHTTP.Get(url);
except
on e:Exception
do
response := e.message;
end;
finally
IdHTTP.Free;
end;
ShowMessage('Response was:' + response);
end;
Could you please give me a hand and help me pinpoint where the problem is?
My indy version is 10.6.2.5298
and I use Delphi 10 Seattle.
Thanks in advance.
I realized I was using very old Open SSL dlls, by getting the latest from GitHub, as advised by Remy Lebeau I managed to make the gethttp call work properly even with a https
endpoint.
So the solution is just use a recent version of the Open SSl dlls.