如何在Delphi中从HTTPS URL获取图像? [英] How to get images from HTTPS URL in Delphi?

查看:97
本文介绍了如何在Delphi中从HTTPS URL获取图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正尝试从URL开始加载 TImage ,如

这样做之后,我得到一个 EIdOSSLCouldNotLoadSSLLibrary 异常,并显示以下消息:

无法加载SSL库.

属性是否存在问题或其他问题?

解决方案

您需要安装在Windows中或与应用程序一起分发的SSL库(两个.DLL文件).

似乎可以在此处下载:

https://slproweb.com/products/Win32OpenSSL.html

或通过其官方网站(但我在那里找不到可下载的二进制文件-仅源代码):

https://www.openssl.org/source/

与Indy一起使用的预编译的.DLL可以在此处下载:

https://indy.fulgan.com/SSL/(感谢Zed)

I'm trying to load a TImage starting from an URL as explained in this answer.

uses
  GIFImg;

procedure TForm1.Button1Click(Sender: TObject);
var
  Stream : TMemoryStream;
  GIF : TGIFImage;
begin
  Stream := TMemoryStream.Create;
  GIF := TGIFImage.Create;
  try
    IdHTTP1.Get('http://www.google.com/intl/en_ALL/images/logo.gif', Stream);
    //IdHTTP1.Get('https://www.google.com/intl/en_ALL/images/logo.gif', Stream);

    Stream.Position := 0;
    GIF.LoadFromStream(Stream);

    Image1.Picture.Assign(GIF);

  finally
    FreeAndNil(GIF);
    FreeAndNil(Stream);
  end;
end;

All works good if the URL starts with a simple HTTP.

When I try to load from an HTTPS URL, I get an EIdIOHandlerPropInvalid exception with message:

IOHandler value is not valid.

I've tried adding a TIdSSLIOHandlerSocketOpenSSL and setting it as IOHandler for the TIdHTTP component.

After doing that, I get an EIdOSSLCouldNotLoadSSLLibrary exception with the following message:

Could not load SSL library.

Is there something wrong in the properties or some other problem?

解决方案

You need the SSL library (two .DLL files) either installed in your Windows, or distributed along with your application.

Seems to be downloadable here:

https://slproweb.com/products/Win32OpenSSL.html

Or via their official web site (but I can't find downloadable binaries there - only source code):

https://www.openssl.org/source/

Pre-compiled .DLLs for use with Indy can be downloaded here:

https://indy.fulgan.com/SSL/ (Thanks, Zed)

这篇关于如何在Delphi中从HTTPS URL获取图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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