TRTH REST API RequestToken issue

Options

Hi Team,


Good day. Since customer in China mainland can't access hosted.datascopeapi.reuters.com, I suggest customer using IP 192.165.219.152 directly to request token. But customer got response "

SSLError(SSLCertVerificationError("hostname '192.165.219.152' doesn't match 'hosted.datascopeapi.reuters.com'")

"

Could you kindly pls advise what is the root cause and how to resolve it ? Many thanks

Best Answer

  • Hi @Gang.Chen,

    SSL Certificates can be limited to a specific domain or sub domain. Requesting to IP address instead of domain name could cause the SSL certification validation failure in the application.

    To avoid the issue, the client can disable certificate validation on the function or library used for the request. For example in Python, please see this question.

Answers

  • Hi Veerapath,

    Thanks for your reply about this. May I know how to disable certificate validation in C# demo example ? One of my customer facing this issue currently. Thanks again.

  • Hi @Gang.Chen,

    For .Net application, below is the sample code to ignore the certificate name mismatch error.

    using System.Net.Security;
    using System.Security.Cryptography.X509Certificates;

    ...

    private Uri dssUri = new Uri("https://192.165.219.152/RestApi/v1/");

    public bool ValidateServerCertificate(
        object sender,
        X509Certificate certificate,
        X509Chain chain,
        SslPolicyErrors sslPolicyErrors)
    {
            if (sslPolicyErrors == SslPolicyErrors.None)
                return true;

            if (sslPolicyErrors == SslPolicyErrors.RemoteCertificateNameMismatch)
            // ignore name mismatch err
                return true;

            Console.WriteLine("Certificate error: {0}", sslPolicyErrors);
            // Do not allow this client to communicate with unauthenticated servers.
            return false;
    }

    public void ConnectToServer(string dssUserName, string dssUserPassword)
    {
        System.Net.ServicePointManager.ServerCertificateValidationCallback = ValidateServerCertificate; 
        extractionsContext = new ExtractionsContext(dssUri, dssUserName, dssUserPassword);
    }
  • For the DSS GUI example, you can add this code in the MainWindow.xaml.cs file.