首页 > 解决方案 > TIdhttp HTTPS 握手失败

问题描述

我正在使用 Indy 10 连接到 SOAP Web 服务。当我在运行 Fiddler 的情况下运行代码时,我发现网络服务器没有协商我们的握手。我附上了 Fiddler Inspectors 的屏幕截图。

我们已经能够使用共享软件应用程序“SoapUI”成功连接到服务器。我附上了使用 SoapUI 时检查员的屏幕截图。

我注意到的一件事是 SoapUI 正在使用不同版本的 SSL/TLS。如何配置 Indy 以使用相同的版本?

关于我的电话为什么失败的任何其他见解?

procedure TForm6.Button1Click(Sender: TObject);
var
  idhttp: TIdhttp;
  IdSSLIOHandlerSocket1 : TIdSSLIOHandlerSocketOpenSSL;
  Params   : TStringStream;
begin
    idhttp := TIdhttp.Create(nil);
    IdSSLIOHandlerSocket1 := TIdSSLIOHandlerSocketOpenSSL.create(nil);
    idhttp.ProxyParams.ProxyServer := '127.0.0.1';
    idhttp.ProxyParams.ProxyPort := 8888 ;
    idhttp.Request.ContentType := 'text/xml';
    idhttp.Request.CharSet:='utf-8';
    idhttp.request.connection := 'keep-alive';
    idhttp.Request.CustomHeaders.AddValue('Content-Type','text/xml;charset=UTF-8');
    idhttp.Request.CustomHeaders.AddValue('SOAPAction','"http://ws.nemsis.org/SubmitData"');
    idhttp.Request.CustomHeaders.AddValue('Host','nemsis.org:443');
    idhttp.Request.BasicAuthentication := True;
    idhttp.request.username := 'xxxxx';
    idhttp.request.password := 'yyyyy';
    with IdSSLIOHandlerSocket1 do begin
      SSLOptions.Method := sslvTLSv1_2;
      SSLOptions.SSLVersions := [sslvTLSv1_2];
      SSLOptions.VerifyMode := [];
      SSLOptions.VerifyDepth := 2;
    end;
    with IdHTTP do begin
      IOHandler := IdSSLIOHandlerSocket1;
    end;
    Params := TStringStream.Create(filetostring(ExtractFileDir(ParamStr(0))+'\sample.xml'));
    idhttp.Post('https://nemsis.org:443/NemsisV3Validator4/NemsisWsService',Params);
end;

通话失败: 在此处输入图像描述

使用 SoapUI 成功调用: 在此处输入图像描述

标签: delphiindyindy10

解决方案


推荐阅读