question

Upvotes
Accepted
5 0 1 0

TRTH REST API RequestToken issue

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

tick-history-rest-api
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvotes
Accepted
11.3k 25 8 13

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.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvotes
5 0 1 0

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.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvotes
11.3k 25 8 13

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);
}
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

For the DSS GUI example, you can add this code in the MainWindow.xaml.cs file.

Click below to post an Idea Post Idea