Cant download file from https

Hi, I try download file from server. It is protected by SSL. And I see exception:

javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.

But with old version of application which is on robovm it works.

    URL u = new URL("https://dl.dropboxusercontent.com/u/19720531/ivan_123.json");
    HttpURLConnection conn = (HttpURLConnection) u.openConnection();
    conn.setConnectTimeout(20000);
    conn.setReadTimeout(20000);
    conn.setAllowUserInteraction(false);
    conn.setUseCaches(false);
    conn.setInstanceFollowRedirects(true);

    // time to get result back
    int statusCode = conn.getResponseCode();//Here is a crash

Thank you

1 Like

Hi,

This is a known issue with MOE 1.2, it is fixed in 1.3 beta.

The solution was already posted to the forum:

And you can also check out the RssReader sample.

Best Regards,
Gergely

Gergely, does this mean that with 1.3-beta we no longer need to copy android_root.etc.security.cacerts folder into the ios resources folder?

Yes, it is included in the SDK by default.

Could you provide instruction how to migrate to 1.3.0 from 1.2.x?
I have an exception about xcode project.

Thank you

I see the same problem when I delete that sertificates from my resources.
version 1.3.0-beta-1

Dear zufarfakhurtdinov,

did you open your Xcode settings and Check the “Copy CA Certificates” checkbox in your main target?

Best Regards,
KristĂłf

1 Like

I cannot do that. Multi-OS Engine Actions is grey. Can I do it with xcode or manually change config?
Actually plugin for 1.3.0-beta1 works bad. I cannot run or debug any config because there is no options for that in run/debug configurations. There is only one app with small test, but I have 6 applications.
p.s. I use EAP. Do you support it? Maybe there is problem.
IntelliJ IDEA 2017.1 EAP
Build #IU-171.2014.21, built on December 29, 2016
IntelliJ IDEA EAP User
Expiration date: January 28, 2017
JRE: 1.8.0_112-release-b621 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o

Dear zufarfakhurtdinov,

yes, you can change this setting from Xcode too:

We know of some issues with the latest IDEA (2016.3.2), however we don’t support/test EAP versions of IDEA/Android Studio.

Best Regards,
KristĂłf

3 Likes

It seems like a magic trick.
But it’s work! Thank you!

actually it doesn’t work. So, I see exception yet

javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
        at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:344)
        at com.android.okhttp.Connection.connectTls(Connection.java:235)
        at com.android.okhttp.Connection.connectSocket(Connection.java:199)
        at com.android.okhttp.Connection.connect(Connection.java:172)
        at com.android.okhttp.Connection.connectAndSetOwner(Connection.java:367)
        at com.android.okhttp.OkHttpClient$1.connectAndSetOwner(OkHttpClient.java:130)
        at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:329)
        at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:246)
        at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:442)
        at com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:118)
        at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.connect(DelegatingHttpsURLConnection.java:89)
        at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:25)
        at com.turbomanage.httpclient.AbstractHttpClient.doHttpMethod(AbstractHttpClient.java:214)
        at com.turbomanage.httpclient.AbstractHttpClient.execute(AbstractHttpClient.java:173)
        at com.turbomanage.httpclient.AbstractHttpClient.get(AbstractHttpClient.java:103)
        at jetbrains.jetpad.transport.http.server.HttpImpl$4.run(HttpImpl.java:91)
        at delightex.platform.EDTUtil$3.run(EDTUtil.java:113)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
        at java.lang.Thread.run(Thread.java:818)
Caused by: java.security.cert.CertificateException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
        at com.android.org.conscrypt.TrustManagerImpl.checkTrusted(TrustManagerImpl.java:318)
        at com.android.org.conscrypt.TrustManagerImpl.checkServerTrusted(TrustManagerImpl.java:219)
        at com.android.org.conscrypt.Platform.checkServerTrusted(Platform.java:120)
        at com.android.org.conscrypt.OpenSSLSocketImpl.verifyCertificateChain(OpenSSLSocketImpl.java:572)
        at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
        at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:340)
        ... 19 more
Caused by: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
        ... 25 more

So, I’ll readd that android sertificates to my own resources.