使用TRESTRequest时来自客户端的未指定证书 [英] Unspecified certificate from client when using TRESTRequest
问题描述
当使用SSL URL调用我们的一台内部服务器时,TRESTClient和TRESTRequest给出并显示错误首先来自Exception Class ENetHTTPCertificateException,然后来自ERESTException并显示消息来自客户端的未指定证书"
When calling one of our Internal servers with SSL URL, TRESTClient and TRESTRequest gives and error first from Exception Class ENetHTTPCertificateException and then from ERESTException with the message 'Unspecified certificate from client'
我知道背后会使用WinInet Api,但是在Delphi Rest Library中这不是将连接设置为忽略证书错误的本机方法-我该怎么编码?
I know that WinInet Api is being used behind, but here is no native way in the Delphi Rest Library to set the connection to Ignore Certificate Errors - How can I code that ?
或
这是否意味着服务器正在请求客户端证书?
Does this mean the server is requesting a client certificate ?
function TdmoRestApi.GetSaLogin(var sErrorText: String): TLoginSvar;
var
LoginRoot: TLoginRootClass;
begin
Result := lsErrVilla;
RESTRequestLogin.Params.ParameterByName('TOKEN').value := FLoginToken;
RESTRequestLogin.Params.ParameterByName('X-CSRF-Token').value := 'Fetch';
try
RESTRequestLogin.Execute; //This call fails
except
on e: Exception do begin
sErrorText := e.ClassName + ' ' + e.message;
if RESTResponseLogin.StatusCode = 0 then
Exit(lsErrVilla);
end;
end;
case RESTResponseLogin.StatusCode of
200: begin
....
400: begin
....
end;
else begin
....
end;
FCsrfToken := RESTResponseLogin.Headers.Values['X-CSRF-Token'];
FLoginSvar := Result;
end;
推荐答案
我找到了解决您问题的方法.我遇到了同样的问题,但是设法忽略了证书验证:
I found the solution to your problem. I had the same problem, but manage to ignore the certificate validation with this:
在RESTClient1组件中,将事件内的以下标志设置为false:
In the RESTClient1 component, set the following flag to false inside the event:
procedure TForm1.RESTClient1AuthEvent(const Sender: TObject; AnAuthTarget:
AuthTargetType; const ARealm, AURL: string; var AUserName, APassword:
string; ar AbortAuth: Boolean; var Persistence: TAuthPersistenceType);
begin
AbortAuth = True;
end;
这篇关于使用TRESTRequest时来自客户端的未指定证书的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!