Search code examples
delphiindydelphi-5idhttp

Error connecting with SSL when posting using Indy


I'm trying to post on a web service via TIdHTTP (Indy) using Delphi 5, and whenever i call the post method, it returns an "Error connecting with SSL error" exception.

This is the code i'm trying to run

FHandle                        := TIdSSLIOHandlerSocket.Create(nil);
FHandle.SSLOptions.Method      := sslvTLSv1;
IdHttp.IOHandler               := FHandle;
IdHttp.HandleRedirects         := True;

IdHTTP.Request.CustomHeaders.Add('Content-Type: application/json');
IdHttp.Request.ContentType := 'application/json';

Load();

vAux := TMemoryStream.Create();
try
  WriteStringToStream(vAux, edJson.Text);
  vAux.Position := 0;
  vRet := IdHTTP.Post(edHost.Text, vAux);
finally
  vAux.Free();
end;

It seems that no matter what i change in CustomHeaders or any other property, the same error happens.

I try changing de SSLOption.Method to all the available ones, but i can't get it to work.

Any suggestion for me to try?


Solution

  • I figured it out what the problem was. It was a certificate file that was faulty on the CertFile property from TIdSSLIOHandlerSocket component and i didn't even realized it was there. After pointing out to the right certificate file everything worked out smoothly. Thank you guys for the insights!