Unspecified certificate from client when using TRESTRequest

前提是你 提交于 2021-02-10 18:15:25

问题


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'

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 ?

or

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;

回答1:


I found the solution to your problem. I had the same problem, but manage to ignore the certificate validation with this:

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;


来源:https://stackoverflow.com/questions/49106557/unspecified-certificate-from-client-when-using-trestrequest

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!