Delphi:idHttp + SSL [英] Delphi: idHttp+SSL

查看:381
本文介绍了Delphi:idHttp + SSL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请解释我如何使用SSL(https://)从服务器下载文件。我没有在互联网上找到合适的答案。

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

每个人都说TIdSSLIOHandlerSocket,但是我只有TIdSSLIOHandlerSocketOpenSSL。
如果我使用TIdSSLIOHandlerSocketOpenSSL,我有一个错误'无法加载SSL库'。
有些人说它需要一个图书馆,但最甚至没有提及。我需要从这里使用图书馆 http://www.indyproject.org/sockets/SSL .EN.aspx

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 ?

我在程序的文件夹中有这些DLL。根据: http://edn.embarcadero.com/article/31279 在运行时,Indy尝试加载libeay32.dll和ssleay32.dll。我不知道Indy试图加载DDL的地方 - >我有一个错误:'无法加载SSL库'。

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;

为什么我有这个错误?
我有Delphi 2010。

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

推荐答案

要使用Indy的OpenSSL类,您需要 ssleay32.dll libeay32.dll 。这可能应该从您尝试执行的Indy代码中的异常来源显而易见。

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.

这些库是从问题中提到的Indy页面链接到的。如果您合法允许这样做,您可以随应用程序分发。将它们放在DLL的任何地方(通常是您的应用程序目录)。

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是抽象TIdSSLIOHandlerSocket类的OpenSSL特定后代。如果您使用其他SSL库而不是OpenSSL,则可以使用不同的后代类。

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.

这篇关于Delphi:idHttp + SSL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆