on 04-20-2016 11:17 AM
Hi All,
I have a requirement to download a file from the HTTPS URL, I have written the code to download the file but when executing the UDF getting error "sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target".
Certificates are imported in the KeyStore, can you please let me know how to access these certificate from UDF?
Below is the code i have written to connect to the URL,
public static void downloadFile(String fileURL, String saveDir, String username, String pwd) throws IOException {
URL url = new URL(fileURL);
String authString = username + ":" + pwd;
System.out.println("auth string: " + authString);
byte[] authEncBytes = Base64.encodeBase64(authString.getBytes());
String authStringEnc = new String(authEncBytes);
HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
httpConn.setRequestProperty("Authorization", "Basic " + authStringEnc);
Thanks,
Tinu
Tinu,
Your certificates would need to be loaded into the keystore of the JVM of your PI Server. The Keystore is called "cacerts"
The reason is that as you are using a direct java call to the HTTP URL, this does not get routed via your PI Keystore in the NWA but this would happen via the JDK/ JVM of your PI Server.
The default keystore password for Java cacerts on your server will be changeit
Regards
Bhavesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Bhavesh,
We used a HTTP call via UDF because the interface flow is PI will receive SOAP request from Third party system , which will have the URL and the file name to be downloaded. The URL will be dynamic. we have to connect to the Third party system and have to download the file.
Thanks,
Tinu
Hi Tinu,
Could you share your final UDF?, i think it will be very helpful for the SCN users.
Regards.
User | Count |
---|---|
91 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.