Page 1 of 1

plugins.http error PKIX path building failed

PostPosted: Tue Mar 08, 2022 7:56 pm
by garroyo
Hi,
I am trying to upload an xml to a web service to be validated. I have read the Servoy documentation for the http plugin but it always gives me the same error when execute the request.
"PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target"
I think it is a problem with the digital certificate that I want to use for sending. I have imported the digital certificate that I want to use for sending to the Java Keystore cacerts but it keeps giving me the same error.
This is the code that I have generated in Servoy and I would appreciate any help or explanation of why it gives me this error and how to solve it so that I can upload the xml to the web service correctly. Thanks.
Code: Select all
function envioTBAI(myXml){
//myXml = path where I have the xml. Example "c:\tmp\TBAI2209713_firma.xml"
var url = "https://tbai-z.prep.gipuzkoa.eus/sarrerak/alta";
var client = plugins.http.createNewHttpClient(); // Creating new http client
var poster = client.createPostRequest(url);

poster.addHeader("Content-Type", "application/xml");
poster.addHeader('Accept', 'application/xml');
poster.setCharset('UTF-8');
   
poster.addFile(null,'XMLTBAI',myXml,'text/xml');

var response = poster.executeRequest()
var pageData = response.getResponseBody();
   
//Get Status Code. 200 is OK
application.output("Response status code: " + response.getStatusCode());
application.output("Response reason: " + response.getStatusReasonPhrase());
application.output("Response body: " + response.getResponseBody());
application.output("Response exception msg: " + response.getException());
   
response.close();
client.close();

return pageData
}

Re: plugins.http error PKIX path building failed

PostPosted: Wed Mar 09, 2022 2:28 am
by robert.edelmann
You should also import any root/intermediate certificates that are missing to your keystore.

The error sounds like something is missing in certificate chain.

Re: plugins.http error PKIX path building failed

PostPosted: Wed Mar 09, 2022 10:15 am
by emera
You probably didn't import the certificate into the right keystore.
For the developer you need to check in the servoy.ini file where -vm points to.

In case of 2022.03 rc1 (windows) it is plugins/com.servoy.eclipse.jre.win32.x86_64_17.0.2/jre/bin/server/jvm.dll
So you must import the certificate to that jre <your servoy install>\developer\plugins\com.servoy.eclipse.jre.win32.x86_64_17.0.2\jre\lib\security