Delphi:IdHTTP + SSL不起作用。没有错误! [英] Delphi: IdHTTP+SSL does not work. No errors!
问题描述
我使用TidHTTP + TIdSSLIOHandlerSocketOpenSSL + 2 DLL:ssleay32.dll和libeay32.dll从的示例:
使用
IdHttp,IdSSLOpenSSL
。
procedure TForm2.Button1Click(Sender:TObject);
var
s:string;
lHTTP:TIdHTTP;
begin
lHTTP:= TIdHTTP.Create(nil);
try
lHTTP.IOHandler:= TIdSSLIOHandlerSocketOpenSSL.Create(lHTTP);
lHTTP.HandleRedirects:= True;
s:= lHTTP.Get('https://esta.cbp.dhs.gov/esta/');
RichEdit1.Text:= s;
finally
lHTTP.Free;
结束
结束
问题可能是您需要部署的DLL的版本。由于最近的版本解决了安全问题,我建议您将Indy版本升级到最新版本,并使用最近的OpenSSL库。
更新:
您是否意味着您无法使用网络浏览器看到该网站,或者当您在HTTP分析器中看不到流量时?正如Rob所说,如果网站使用常规的网络浏览器不可见,那么问题可能不是您的应用程序。
I use TidHTTP + TIdSSLIOHandlerSocketOpenSSL + 2 DLLs: ssleay32.dll and libeay32.dll from http://indy.fulgan.com/SSL.
But I can see all work of my program in HTTP Analyzer! It works as HTTP, not as HTTPS. If I use Opera I cannot see downloading with the same site (https://esta.cbp.dhs.gov/esta).
I did not set any special parameters for TidHTTP and TIdSSLIOHandlerSocketOpenSSL (may be I must but I do not know what exactly).
Must I use TIdSSLVersion(sslvSSLv23) + location of a SSL certificate? Where can I get this certificate? Or only RootCertFile?
How to change a port of idHttp to 443 (must I do it?)?
I use:
procedure TForm1.FormCreate(Sender: TObject);
var mem:tmemorystream;
begin
try
mem:=TMemoryStream.Create();
try
idhttp1.Get('https://esta.cbp.dhs.gov/esta/',Mem);
except
on E : Exception do ShowMessage(E.Message);
end;
finally
mem.Free;
idhttp1.Free;
end;
end;
Please see my video: http://liga-installer.realservers.info/ssl.mp4
Screen shots:
Thanks Thanks Thanks for help!!!
This simple example works in Delphi XE out of the box, so you don't need to change ports or use a certificate on the client side. It's based on an example from RosettaCode:
Uses
IdHttp, IdSSLOpenSSL
...
procedure TForm2.Button1Click(Sender: TObject);
var
s: string;
lHTTP: TIdHTTP;
begin
lHTTP := TIdHTTP.Create(nil);
try
lHTTP.IOHandler := TIdSSLIOHandlerSocketOpenSSL.Create(lHTTP);
lHTTP.HandleRedirects := True;
s := lHTTP.Get('https://esta.cbp.dhs.gov/esta/');
RichEdit1.Text := s;
finally
lHTTP.Free;
end;
end;
The problem is probably the version of the DLLs you need to deploy. Since recent versions fix security issues, I recommend upgrading your version of Indy to the latest and using the most recent OpenSSL libraries from the fulgan site.
Update: Did you mean that you can't see the site using a web browser, or that when you do you can't see the traffic in your HTTP analyser? As Rob mentioned, if the site isn't visible using a regular web browser, then the problem likely isn't your application.
这篇关于Delphi:IdHTTP + SSL不起作用。没有错误!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!