Box Java SDK Connection Problem SSLHandshakeException SunCertPathBuilderException
I am new to Box and using the example from https://github.com/box/box-java-sdk Below is the Java source code and the full error messages after it runs in my office computer with company network, but the same Java code works fine in my home network. It might be the issue of the company firewall. I just want to check if there is any idea or work around. Again, I very appreciate any kind help on this.
public static void main(String[] args) {
BoxAPIConnection api = new BoxAPIConnection("rX9DI8OHvikiLJigQbEbdP8EnxzhV9J6");//("your-developer-token");
BoxFolder rootFolder = BoxFolder.getRootFolder(api);
for (BoxItem.Info itemInfo : rootFolder) {
System.out.format("[%s] %s\n", itemInfo.getID(), itemInfo.getName());
}
}
Exception in thread "main" com.box.sdk.BoxAPIException: Couldn't connect to the Box API due to a network error.
at com.box.sdk.BoxAPIRequest.trySend(BoxAPIRequest.java:395)
at com.box.sdk.BoxAPIRequest.send(BoxAPIRequest.java:209)
at com.box.sdk.BoxAPIRequest.send(BoxAPIRequest.java:184)
at com.box.sdk.JSONIterator.loadNextPage(JSONIterator.java:74)
at com.box.sdk.JSONIterator.loadNextJsonObject(JSONIterator.java:90)
at com.box.sdk.JSONIterator.hasNext(JSONIterator.java:32)
at com.box.sdk.BoxItemIterator.hasNext(BoxItemIterator.java:28)
at org.kp.smartquote.client.view.BoxAccount.main(BoxAccount.java:26)
Caused by: 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
at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1904)
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:279)
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:273)
at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1446)
at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:209)
at sun.security.ssl.Handshaker.processLoop(Handshaker.java:901)
at sun.security.ssl.Handshaker.process_record(Handshaker.java:837)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1023)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1332)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1359)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1343)
at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:563)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:153)
at com.box.sdk.BoxAPIRequest.trySend(BoxAPIRequest.java:393)
... 7 more
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:385)
at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:292)
at sun.security.validator.Validator.validate(Validator.java:260)
at sun.security.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:326)
at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:231)
at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:126)
at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1428)
... 18 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:196)
at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:268)
at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:380)
... 24 more
-
you need this:
http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html
and put the files in jre/lib/security
-
I updated policy files US_export_policy.jar and local_policy.jar in the \jre\lib\security and got the same error as before. Also if I remove the 2 policy files and it gives me java.lang.SecurityException: Cannot locate policy or framework files! So there is issue beyond that, but thanks for the quick help.
-
Finally, the company product supporter points me the right direction. There is a piece of security software called "Netskope Client" and it blocks the connection. It will produce these security/certification errors when it is enabled and in conjunction with the company network since the same code always works with my home network. If it is disabled, it works fine within company network and no more errors.
-
This is not working,
wrote:you need this:
http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html
and put the files in jre/lib/security
Please sign in to leave a comment.
Comments
7 comments