TXDataClient : Unexpected NetHTTPCertificateException on Linux "Server Certificate Invalid or not present"

Hi,

I'm trying to call a XDataServer from within another XDataserver using TXDataClient.

This works fine on Windows, but not within an apache webbroker. I haven't tested on Linux without apache, but I'm convinced that that would trow the same error. I probably need to add something to the TXDataClient, but couldn't find any information for Linux.

{
    "error": {
        "code": "NetHTTPCertificateException",
        "message": "Server Certificate Invalid or not present"
    }
}

The certificate is fine: it works on Windows and browsers also accept the certificate.

The code:

var
  Client : TXDataClient;
  XDataService : IMonitoringService;
begin
  Client := TXDataClient.Create;
  try

    Client.Uri := 'https://staging-lmsserver.evo-it.nl/lmsserver';

    XDataService := Client.Service<IMonitoringService>;
    result := XDataService.healthcheck;
  finally
    Client.Free;
  end;
end;

Interface:

unit UnMonitoring;

interface

uses
  XData.Service.Common;

type
  [ServiceContract]
  [Route('')]
  IMonitoringService = interface(IInvokable) ['{C6D8E238-900D-4DD5-9030-93DC79CFD2F8}']
    // By default, any service operation responds to (is invoked by) a POST request from the client.
    [Route('healthcheck')]
    [HttpGet] function Healthcheck: string;
  end;

implementation

initialization
  RegisterServiceType(TypeInfo(IMonitoringService));

end.

Everything works fine using TRestClient, TRestRequest and TRestResponse. So I implemented that for the meantime.

Thank you!

What do you mean by this? You are using a different code and it works? Can you share the code?

This URL: https://staging-lmsserver.evo-it.nl/lmsserver doesn't work, is it the real URL you are trying to reach?

Hi Wagner

Te endpoint is https://staging-lmsserver.evo-it.nl/lmsserver/healthcheck. But XDataClient does add the 'healthcheck' to the uri.

The working code does not use XDataClient:

  RESTClient := TRestClient.Create(nil);
  RESTRequest := TRestRequest.Create(nil);
  RESTResponse := TRestResponse.Create(nil);
  Try
    RESTClient.ContentType := 'application/json';
    RESTClient.BaseURL := 'https://staging-lmsserver.evo-it.nl/';

    RESTRequest.Resource := 'lmsserver/healthcheck';
    RESTRequest.Accept := 'application/json, text/plain; q=0.9, text/html;q=0.8,';
    RESTRequest.Method := TRESTRequestMethod.rmGET;
    RESTRequest.AutoCreateParams := False;
    RESTRequest.Params.Clear;
    RESTRequest.ClearBody;
    RESTRequest.Client := RESTClient;
    RESTRequest.Response := RESTResponse;

    RESTRequest.Execute;

  Finally
    RESTRequest.Free;
    RESTResponse.Free;
    RESTClient.Free;
  End;

Do you mind checking it with a console application? Then you can send it to us so we can try to reproduce here and investigate better what is going on. That is strange, especially because on Linux XData client uses the same underlying HTTP client used by TRestClient.

Hi Wagner,

Of course. I have an appointment now, but I'll come back to you when I've the results.