While calling download api using sdk, the following error appear, PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException

We are referring the source code present in the following link:

We are using Java SDK version 4.4.0 and we are using access token to download the file.

The following error appears on console.
Exception in thread “main” com.box.sdk.BoxAPIException: Couldn’t connect to the Box API due to a network error. Request
Request{method=GET, url=https://api.box.com/2.0/files/1272892556500/content, headers=[Authorization:Bearer 1!ETxoNz6dUMSorm8bqE2ahvpMpH0emmKQcPBBzokGDEQET6mIXtTv8WbBr-A274DvRG1rslGh_Og3XBI6tVtbI8OvZdw7vMN6ccGEuWjgbFoqrEvOCqDAs1eWTFFOH8ChTY_HAOEsOfQeLvmFO9EZF0Z_GkcDbgiulPBoM794GU7Db1pee4l3S41Nejp3k94KHIZ4H_76tMHtdV5chIk2cZBgVyfXVYYSt5h1wC3TbJosv9CAfo3AzikwTPSI3T2BtzVUfTWoQAtnPTzNYeBlnJ7bcTB1I4xIkm_Ujzt79q8w1iSqtsCpRBclpjZWc0EyOejsJPUKxJElH2fT9jIVTWmyarVX7P6tlAl8v_4EjqkHZf23r3Ql7oyLZ-e11tUNq4yg., User-Agent:Box Java SDK v4.4.0 (Java 1.8.0_241), X-Box-UA:agent=box-java-sdk/4.4.0; env=Java/1.8.0_241, Accept-Charset:utf-8]}
at com.box.sdk.BoxAPIConnection.executeOnClient(BoxAPIConnection.java:1260)
at com.box.sdk.BoxAPIConnection.execute(BoxAPIConnection.java:1249)
at com.box.sdk.BoxAPIRequest.trySend(BoxAPIRequest.java:610)
at com.box.sdk.BoxAPIRequest.send(BoxAPIRequest.java:380)
at com.box.sdk.BoxAPIRequest.send(BoxAPIRequest.java:347)
at com.box.sdk.BoxFile.download(BoxFile.java:310)
at com.box.sdk.BoxFile.download(BoxFile.java:298)
at com.box_bulk_upload.App.main(App.java:61)
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:1946)
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:316)
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:310)
at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1640)
at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:223)
at sun.security.ssl.Handshaker.processLoop(Handshaker.java:1037)
at sun.security.ssl.Handshaker.process_record(Handshaker.java:965)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1064)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1367)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1395)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1379)
at okhttp3.internal.connection.RealConnection.connectTls(RealConnection.kt:379)
at okhttp3.internal.connection.RealConnection.establishProtocol(RealConnection.kt:337)
at okhttp3.internal.connection.RealConnection.connect(RealConnection.kt:209)
at okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.kt:226)
at okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.kt:106)
at okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.kt:74)
at okhttp3.internal.connection.RealCall.initExchange$okhttp(RealCall.kt:255)
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:32)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
at okhttp3.internal.connection.RealCall.execute(RealCall.kt:154)
at com.box.sdk.BoxAPIConnection.executeOnClient(BoxAPIConnection.java:1258)
… 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:450)
at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:317)
at sun.security.validator.Validator.validate(Validator.java:262)
at sun.security.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:330)
at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:227)
at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:132)
at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1622)
… 32 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.provider.certpath.SunCertPathBuilder.build(SunCertPathBuilder.java:141)
at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:126)
at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:280)
at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:445)

Hello,

does this happen always? Have you tried other endpoints?

What authentication method you are using. Can you share your code on how you obtain the connection?