cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

connect to https REST API

SV_8161180
2-Guest

connect to https REST API

Hello,

I have a thing which has multiple services that call REST API's.

Script is:

var url = 'https://url_to_api/api/controller/Action?param1=' + INPUT1 + '&userName='  + User;

var params = {

  url: url /* STRING */,

};

var result = Resources["ContentLoaderFunctions"].GetText(params);

the url used to be HTTP and everything worked great.

Now the url is https and when I test my service I get the following error:

Wrapped javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target Cause: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

Does anybody know what I have to do to get this working.

1 ACCEPTED SOLUTION

Accepted Solutions
jrajesh
7-Bedrock
(To:CRArko)

Hi,

 

I had to give the following to tomcat configuration Java options and only then it worked:

-Djavax.net.ssl.trustStore=C:\Program Files\Java\jre1.8.0_161\lib\security\cacerts

 

Thanks and Regards,

Jyothi

View solution in original post

9 REPLIES 9

Hi Sven

Your rest request is using https, which will suggest you will need to enable ignoreSSLError to true.

var params = {

proxyScheme: undefined /* STRING */,

headers: undefined /* JSON */,

ignoreSSLErrors: true/* BOOLEAN */,

useNTLM: undefined /* BOOLEAN */,

workstation: undefined /* STRING */,

useProxy: undefined /* BOOLEAN */,

withCookies: undefined /* BOOLEAN */,

proxyHost: undefined /* STRING */,

url: undefined /* STRING */,

timeout: undefined /* NUMBER */,

proxyPort: undefined /* INTEGER */,

password: undefined /* STRING */,

domain: undefined /* STRING */,

username: undefined /* STRING */

};

var result = Resources["ContentLoaderFunctions"].GetText(params);

I still get the error

Have you successfully tried using Postman with this https request?

This could tell us if it is a Thingworx problem or this could be an API certificate issue.

Yes, calls with postman are successful.

Since it is complaining about certificates, could it be I am somehow missing a certificate.

I added all certificates involving the called api to the java keystore.

Have you got any further details on your application logs?

Found the error. I was adding the certificates to the wrong keystore.

Hi,

 

Which keystore should be used to import the certificate? I used the Java cacerts that ThingWorx tomcat is using. It still does not work for me.

 

Thanks and Regards,

Jyothi

CRArko
17-Peridot
(To:SV_8161180)

Hello.

 

Has this issue been resolved by importing to the correct keystore? If so, can you tell us which keystore was correct, and mark that as an Accepted Solution?

 

If there are still any problems, let us know that as well.

 

Thanks!

 

-- Craig A.

jrajesh
7-Bedrock
(To:CRArko)

Hi,

 

I had to give the following to tomcat configuration Java options and only then it worked:

-Djavax.net.ssl.trustStore=C:\Program Files\Java\jre1.8.0_161\lib\security\cacerts

 

Thanks and Regards,

Jyothi

Top Tags