德尔福:idHttp+SSL [英] Delphi: idHttp+SSL

查看:45
本文介绍了德尔福: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;

为什么会出现这个错误?我有德尔福 2010.

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

推荐答案

要使用 Indy 的 OpenSSL 类,您需要 ssleay32.dlllibeay32.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.

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

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