Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X
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.
Solved! Go to Solution.
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
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
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.
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