问题
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