我有一个休息连接(用户名和密码保护),我想忽略 SSL 证书检查。
在 C# 中:
public class TrustAllCertificatePolicy : ICertificatePolicy
{
private const uint CERT_E_UNTRUSTEDROOT = 0x800B0109;
public TrustAllCertificatePolicy()
{
}
public bool CheckValidationResult(ServicePoint sp,
X509Certificate cert, WebRequest req, int problem)
{
bool returnValue = problem == 0;
if ((uint)problem == CERT_E_UNTRUSTEDROOT)
returnValue = true;
return returnValue;
}
}
我想在 Delphi 2007 中做同样的事情。有可能吗?
其实我这样做:
URL:= 'https://hw1200122:8444/WsConduit/ConduitService/SyncData/1';
HttpClient := TIdHttp.Create(nil);
HttpClient.ConnectTimeout := 5000;
HttpClient.ReadTimeout := 5000;
HttpClient.OnAuthorization := httpAuthorization;
HttpClient.MaxAuthRetries := 0;
HttpClient.HTTPOptions := [hoInProcessAuth];
HttpClient.Request.RawHeaders.Clear;
HttpClient.Request.RawHeaders.AddStrings(Self.FHeaders);
HttpClient.Request.BasicAuthentication := true;
HttpClient.Request.Username := Self.FUsername;
HttpClient.Request.Password := Self.FPassword;
httpClient.Request.ContentType := 'application/zip';
LHandler := TIdSSLIOHandlerSocketOpenSSL.Create(nil);
httpClient.IOHandler := LHandler;
try
respStr := httpClient.Get(URL);
Result.ResponseCode := httpClient.ResponseCode;
Result.ResponseStr := respStr;
except
on E: EIdHTTPProtocolException do
begin
Result.ResponseCode := httpClient.ResponseCode;
Result.ResponseStr := E.Message;
end;
end;
我收到 404 错误:
'HTTP/1.1 404 未找到'
有什么问题?