plugins.http error PKIX path building failed

Questions and answers on designing your Servoy solutions, database modelling and other 'how do I do this' that don't fit in any of the other categories

plugins.http error PKIX path building failed

Postby garroyo » Tue Mar 08, 2022 7:56 pm

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
}
garroyo
 
Posts: 14
Joined: Mon Jan 23, 2017 2:01 pm

Re: plugins.http error PKIX path building failed

Postby robert.edelmann » Wed Mar 09, 2022 2:28 am

You should also import any root/intermediate certificates that are missing to your keystore.

The error sounds like something is missing in certificate chain.
mit freundlichen Grüßen
Robert Stefan Edelmann
User avatar
robert.edelmann
 
Posts: 91
Joined: Wed Aug 14, 2013 6:12 pm

Re: plugins.http error PKIX path building failed

Postby emera » Wed Mar 09, 2022 10:15 am

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
emera
 
Posts: 44
Joined: Tue Jun 17, 2014 8:33 am


Return to Programming with Servoy

Who is online

Users browsing this forum: No registered users and 13 guests