Delphi: idHttp+SSL

孤者浪人 提交于 2019-11-26 22:18:31

问题


Explain me please how to download a file from a server using SSL (https://). I have not found an appropriate answer in the Internet.

Everybody says about TIdSSLIOHandlerSocket, but I have only TIdSSLIOHandlerSocketOpenSSL. I have an error 'could not load SSL library' if I use TIdSSLIOHandlerSocketOpenSSL. Some people say it needs a library, but the most even do not mention about it. Do I need to use libraries from here http://www.indyproject.org/sockets/SSL.EN.aspx ?

I have those DLLs in program's folder. According to: http://edn.embarcadero.com/article/31279 "At runtime, Indy attempts to load libeay32.dll and ssleay32.dll." I do not know from where Indy tries to load the DDLs -> I have an error: 'Could not load SSL library.'

procedure TForm1.FormCreate(Sender: TObject);
    var  UpdateMemoryStream:tmemorystream;
    begin
    try
    UpdateMemoryStream:=TMemoryStream.Create;
                try
                idhttp2.Get('https://example.com/list.rar',UpdateMemoryStream); //I have: Exception class EIdOSSLCouldNotLoadSSLLibrary with message 'Could not load SSL library.'
                except
                    on E : Exception do 
                    begin showmessage('Error: '+E.Message); 
                    end;
                end;
    UpdateMemoryStream.SaveToFile('d:\1.rar');
    finally
    UpdateMemoryStream.Free;
    end;
    end;

Why do I have this error? I have Delphi 2010.


回答1:


To use Indy's OpenSSL class, you need ssleay32.dll and libeay32.dll. That probably should have been apparent from the source of the exception in the Indy code you tried to execute.

The libraries are linked to from the Indy page mentioned in the question. If you're legally allowed to do so, you can distribute them with your application. Put them wherever DLLs go (usually your application directory).

TIdSSLIOHandlerSocketOpenSSL is an OpenSSL-specific descendant of the abstract TIdSSLIOHandlerSocket class. If you were using some other SSL library instead of OpenSSL, you'd use a different descendant class.




回答2:


Download openssl-1.0.0d-i386-win32-rev2.zip , not openssl-1.0.0d-x64_86-win64-rev2.zip from http://indy.fulgan.com/SSL/

Read here too: https://forums.embarcadero.com/thread.jspa?threadID=15569




回答3:


It is essential to get the correct DLLs as some are compiled with links to M$ Studio and therefore do not work in Delphi. Try https://indy.fulgan.com/SSL/ Latest versions are at the bottom of the page.



来源:https://stackoverflow.com/questions/6683127/delphi-idhttpssl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!