当我将IdHTTP客户端组件与SOCKS5代理服务器结合使用并使用SSL时,我会得到一个通用的Indy错误。
IdHTTP代理(和一个非https )中使用SOCKS5组件,那么一切都可以正常工作。IdHTTP组件(而不使用SOCKS5代理),那么所有操作都没有问题。IdHTTP组件与SSL和SOCKS5代理一起使用,则会得到以下错误:错误输出的Line 405 idSocks.pas (raise EIdSocksServerGeneralError.Create(RSSocksServerGeneralError);
这是我的密码
var
HTTP : TIdHTTP;
Cookie : TIdCookieManager;
SSL : TIdSSLIOHandlerSocketOpenSSL;
Params : TStringList;
HTMLSource : String;
CurrentProxy : String;
ProxyPort : Integer;
ProxyHost : String;
ProxyUsername : String;
ProxyPW : String;
begin
Synchronize(AddItem);
HTTP := TIdHTTP.Create(NIL);
Cookie := TIdCookieManager.Create(HTTP);
SSL := TIdSSLIOHandlerSocketOpenSSL.Create(HTTP);
HTTP.CookieManager := Cookie;
HTTP.IOHandler := SSL;
HTTP.HandleRedirects := True;
Params := TStringList.Create;
HTTP.Request.UserAgent := Task^.Useragent;
try
while True do begin
if terminated then Exit;
Params.Clear;
Cookie.CookieCollection.Clear;
if Task^.Proxytype >= 0 then begin // if proxy enabled
CurrentProxy := Task^.Form.GetProxyFromPool;
ProxyHost := ParsingW(':', CurrentProxy, 1);
ProxyPort := strtoint(ParsingW(':', CurrentProxy, 2));
HTTP.ConnectTimeout := (Task^.Proxytimeout * 1000);
if Task^.ProxyAuth then begin
ProxyUsername := ParsingW(':', CurrentProxy, 3);
ProxyPW := ParsingW(':', CurrentProxy, 4);
end;
end;
if Task^.Proxytype = 0 then begin //HTTP(s)
HTTP.ProxyParams.ProxyServer := ProxyHost;
HTTP.ProxyParams.ProxyPort := ProxyPort;
if Task^.ProxyAuth then begin
HTTP.ProxyParams.ProxyUsername := ProxyUsername;
HTTP.ProxyParams.ProxyPassword := ProxyPW;
end;
end;
if (Task^.Proxytype = 1) or (Task^.Proxytype = 2) then begin // Socks 4 or 5
SSL.TransparentProxy := TIdSocksInfo.Create(HTTP);
(SSL.TransparentProxy as TIdSocksInfo).Port := ProxyPort;
(SSL.TransparentProxy as TIdSocksInfo).Host := ProxyHost;
if Task^.ProxyAuth then begin
(SSL.TransparentProxy as TIdSocksInfo).Username := ProxyUsername;
(SSL.TransparentProxy as TIdSocksInfo).Password := ProxyPW;
(SSL.TransparentProxy as TIdSocksInfo).Authentication := saUsernamePassword;
end else begin
(SSL.TransparentProxy as TIdSocksInfo).Authentication := saNoAuthentication;
end;
if (Task^.Proxytype = 1) then (SSL.TransparentProxy as TIdSocksInfo).Version := svSocks4;
if (Task^.Proxytype = 2) then (SSL.TransparentProxy as TIdSocksInfo).Version := svSocks5;
end;我是错过了什么,还是不可能用Socks5代理连接到SSL站点?
发布于 2013-09-25 15:56:02
您正在引发一个EIdSocksServerGeneralError,这意味着TIdHTTP正在成功地与SOCKS代理进行通信,并且它正在验证您的请求,即在没有身份验证的情况下访问它,但它随后无法与您在HTTPS url中指定的目标服务器建立连接。代理使用错误代码1(一般故障)进行应答。确保网址是准确的。要么代理无法将主机名解析为IP (尝试在url中指定IP而不是主机名并查看其是否有区别),要么代理没有到达该IP的有效路由,或者代理端正在发生其他错误。如果您可以访问代理,请试着查看它的日志,看看到底出了什么问题。
https://stackoverflow.com/questions/19001591
复制相似问题