Error when using box-java-sdk
Hello ,when i try to connect to box from java sdk i get the following error.
Looks like JDK security not able to validate or check box certificate.any help on this please
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 boxtester.test.main(test.java:11)
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(Unknown Source)
at sun.security.ssl.SSLSocketImpl.fatal(Unknown Source)
at sun.security.ssl.Handshaker.fatalSE(Unknown Source)
at sun.security.ssl.Handshaker.fatalSE(Unknown Source)
at sun.security.ssl.ClientHandshaker.serverCertificate(Unknown Source)
at sun.security.ssl.ClientHandshaker.processMessage(Unknown Source)
at sun.security.ssl.Handshaker.processLoop(Unknown Source)
at sun.security.ssl.Handshaker.process_record(Unknown Source)
at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.afterConnect(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(Unknown Source)
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(Unknown Source)
at sun.security.validator.PKIXValidator.engineValidate(Unknown Source)
at sun.security.validator.Validator.validate(Unknown Source)
at sun.security.ssl.X509TrustManagerImpl.validate(Unknown Source)
at sun.security.ssl.X509TrustManagerImpl.checkTrusted(Unknown Source)
at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(Unknown Source)
... 19 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.provider.certpath.SunCertPathBuilder.build(Unknown Source)
at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(Unknown Source)
at java.security.cert.CertPathBuilder.build(Unknown Source)
... 25 more
-
I get a similar error. This exact code worked fine yesterday!!
com.box.sdk.BoxAPIException: Couldn't connect to the Box API due to a network error. at com.box.sdk.BoxAPIRequest.writeBody(BoxAPIRequest.java:320) at com.box.sdk.BoxAPIRequest.trySend(BoxAPIRequest.java:389) at com.box.sdk.BoxAPIRequest.send(BoxAPIRequest.java:209) at com.box.sdk.BoxAPIRequest.send(BoxAPIRequest.java:184) at com.box.sdk.BoxAPIConnection.refresh(BoxAPIConnection.java:464) at com.box.sdk.BoxAPIConnection.getAccessToken(BoxAPIConnection.java:266) at QBox.setupBoxAPIConnection(QBox.java:71) at QBox.(QBox.java:45) at QBox.main(QBox.java:35) 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:1949) at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:302)
-
I am not 100% sure why you are seeing this error. Please take a look at this StackOverflow thread, which has a few potential fixes for this issue. In addition to the fixes suggested on StackOverflow, please take a look at this thread from this forum, which might be related to this issue.
-
See my post https://community.box.com/t5/Developer-Forum/Box-Java-SDK-Connection-Problem-SSLHandshakeException/m-p/27133/highlight/true#M1288 for the same error. It always leads me to research the valid certification and firewall, but it ends with no luck. For my case, it is the security software "Netscope Client" on my machine blocking the access and causing the above error.
It is most likely the same issue and you have to disable the security software. I would also suggest to run your same code on different computers and networks since it definitely can work. The same code is very likely running fine on your personal computer/network without these errors. Hope it is as easy as disabling a piece of security software or at least can help you narrow down the cause of the problem.
サインインしてコメントを残してください。
コメント
5件のコメント