1
votes

i'm using Delphi 2007 and Indy 10 to make a https post request, I'm testing with httpbin but it does not work... it's raising:

First chance exception at $77503E28. Exception class EIdOSSLCouldNotLoadSSLLibrary with message 'Could not load SSL library.'. Process Recarga.exe (21392)

Here's my code:

unit UMAIN;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, IdHttp, IdMultipartFormData, IdSSLOpenSSL;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
const
  URL = 'https://httpbin.org/post';
var
  idHttp: TIdHTTP;
  data: TIdMultiPartFormDataStream;
  retorno: string;
  LHandler: TIdSSLIOHandlerSocketOpenSSL;
begin
  idHttp:= TIdHTTP.Create(nil);
  data := TIdMultiPartFormDataStream.Create;
  LHandler := TIdSSLIOHandlerSocketOpenSSL.Create(nil);
  with LHandler do
    begin
      SSLOptions.Method := sslvSSLv2;
      SSLOptions.Mode := sslmUnassigned;
      SSLOptions.VerifyMode := [];
      SSLOptions.VerifyDepth := 0;
      host := '';
    end;

  data.AddFormField('serv', 'atualizar');

  try
    try
      idHttp.IOHandler := LHandler;
      idHttp.Request.Accept := 'text/html, */*';
      idHttp.Request.UserAgent := 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0';
      idHttp.Request.ContentType := 'application/x-www-form-urlencoded';
      idHttp.HandleRedirects := True;
      retorno := UTF8Decode(idHttp.Post(URL, data));
      ShowMessage('Resultado: ' + retorno);
    except on E: Exception do
      ShowMessage('Erro: ' + E.Message);
    end;
  finally
    LHandler.Free;
    idHttp.Free;
  end;

end;

end.

I was read here in SO and other sites that I need libeay32.dll and ssleay32.dll libraries but I do have them and in the same directory that resides my final exe, and nothing works as I said above. What's wrong? Is that a bug?

1
Do some debugging. Work out why the DLLs are not loading. Use the debugger. You have all the code. Check what GetLastError returns when LoadLibrary fails. - David Heffernan
You need to upgrade your extremely buggy extremely OLD version of Indy. The versions that shipped with Delphi 2007 are unacceptable. - Warren P
Thanks for your help, I will update it soon. - Anderson Madeira
BTW, why is this question so downvoted? Isn't SO supposed to serve as a database for questions and answers regarding programming? IMHO as a database for Q&A, it should contain as many of them as possible, even if some of them are considered old; some day in the future those old questions may be very useful. I don't see "old stuff" here. Downvoting is a privilege, please use it carefully. - Anderson Madeira

1 Answers

1
votes

I had to test many dlls before getting one to work, acording to this answer I needed a specific version of the dlls. After struggling and testing all openssl versions provided by Indy, the 9.6 one worked for me.