Load DLL SSL - Delphi

Asked

Viewed 1,191 times

0

I’m having trouble downloading files with https:/protocol. Looking for information, I was informed that I should load the DLL. I found people showing "how it carries", but as I have never performed this procedure, I’m having a lot of difficulty.

Before I had tried to add the component of Indy, but got errors, why this is my "last solution":

uses: IdHTTP, IdSSLOpenSSL;

IdHTTP1 := TIdHTTP.create(nil);
 try
            IdHTTP1.IOHandler := TIdSSLIOHandlerSocketOpenSSL.Create(nil);  
            IdHTTP1.Request.Accept := 'text/html, */*';
            IdHTTP1.Request.UserAgent := 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0';
            IdHTTP1.Request.ContentType := 'application/x-www-form-urlencoded';
            IdHTTP1.HandleRedirects := True;
            IdHTTP1.get(FNomeArq,MS);
            Ms.Seek(0,soFromBeginning);
            header := IdHTTP1.Response.ContentType;
 except on E : EIdHTTPProtocolException do begin
             showmessage(intToStr(IdHTTP1.ResponseCode));
            end;
            on E: EIdSocketError do begin
                showmessage(intToStr(IdHTTP1.ResponseCode));
            end;
            on E: Exception do begin
              showmessage(intToStr(IdHTTP1.ResponseCode));
            end;
 end;

I made an application that uses openssl Dlls ( libeay32.dll and ssleay32.dll ). It is Indy to use them, I do not call the Dlls directly.

The simplest solution I found to avoid an installer (i just delpoy an exe and I’m ok with this approach) is:

put the Dlls as exe resources at the beginning of the program I extract them in the exe folder the exe uses them

I downloaded the DLL’s here:

http://indy.fulgan.com/SSL/

I took some examples on the internet, but I didn’t get any success:

procedure TForm1.Button2Click(Sender: TObject);

type

  // vamos declarar um tipo function
  TSomarFuncao = function(a, b: Integer): Integer; stdcall;
var
  Somar: TSomarFuncao; // uma variável que representará a função
  DLLHandle: THandle; // este é o handle para a DLL
begin
  // vamos carregar a DLL
  DLLHandle := LoadLibrary('\dll\libeay32.dll');
  DLLHandle := LoadLibrary('\dll\ssleay32.dll');
  try
    // vamos obter o endereço da função na DLL
    Somar := GetProcAddress(DLLHandle, 'Somar');

    // vamos chamar a função agora
    if Assigned(Somar) then
      ShowMessage(IntToStr(Somar(4, 3)))
    else
      ShowMessage('Não foi possível chamar a rotina desejada');
  finally
    FreeLibrary(DLLHandle); // vamos liberar a DLL
  end;

end;

How do I load these DLL’s into my application?

  • Consider using Indy instead of trying to do this manually.

  • My problem is it’s not working with Indy...

  • It’ll be a lot easier to try to make it work with Indy than to try to do it manually. Anyway you will have to use Indy to send the requests will not? What other component would you use?

  • The Component in question is Tidssliohandlersocketopenssl

  • How far have you gone to make it work with Indy? Post your progress to try to help you.

  • I added the code that contained the TIdSSLIOHandlerSocketOpenSSL , but as I said, it did not work generated error... then in a topic I was told to add the DLL. In my case I use Delphi XE5, and do not format the PC for more or less 3 years... ATT

  • How are Iohandler’s properties? Could you make a code for minimal reproduction of the problem by creating the components in Runtime instead of design time? It could be a console application... This way we can analyze if any configuration is missing.

  • Also, describe the errors that are happening. This makes it easier to solve the problem. Another important piece of information is where the problem is occurring, in other words, which line generates an exception?

  • Good afternoon @Eprogrammernotfound, the error that was appearing was this: eidosslcouldnotloadssllibrary could not load ssl library. ATT

  • Call the function WhichFailedToLoad and post the result of the missing functions

  • Ever tried to put the . Dll in the application folder? .

Show 6 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.