Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How do you use WWW with HTTPS in Android? I'm getting an SSLHandshakeException

Discussion in 'Android' started by Dreamwriter, Dec 3, 2013.

  1. Dreamwriter

    Dreamwriter

    Joined:
    Jul 22, 2011
    Posts:
    472
    I've realized this is Android-specific - my code works perfectly in iOS. I'm doing a standard HTTP POST using the WWW class, and my stuff works on our private test server. I switched to a public server that requires HTTPS, and while it works fine in iOS with no changes excerpt the URL, in Android I get this:

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

    Any idea? I found a few places on the internet suggesting things like this:

    System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; };

    ...but the callback is never called, making me think it doesn't work with WWW.
     
  2. Agent_007

    Agent_007

    Joined:
    Dec 18, 2011
    Posts:
    899
  3. Dreamwriter

    Dreamwriter

    Joined:
    Jul 22, 2011
    Posts:
    472
    Thanks, seems crazy that Unity doesn't support self-signed certificates with Android yet does in iOS. And it doesn't support .net WebRequest either, so doing it manually seems out of the cards too.

    This is frustrating, we don't want to pay for some authentication when our game is just trying to communicate with our own server.
     
  4. Dreamwriter

    Dreamwriter

    Joined:
    Jul 22, 2011
    Posts:
    472
    Actually, it's not working with a well known CA either, we tried that and I get the exact same error on Android.
     
  5. Agent_007

    Agent_007

    Joined:
    Dec 18, 2011
    Posts:
    899
    Then you should do a bug report for that.
     
  6. ___Petr___

    ___Petr___

    Joined:
    Jun 4, 2013
    Posts:
    40
    Any news?
    We have such problems too.
     
  7. bakno

    bakno

    Joined:
    Mar 18, 2007
    Posts:
    604
    Was this solved?

    We are having the same problem.

    Please help!
     
  8. BlackFly

    BlackFly

    Joined:
    Mar 24, 2015
    Posts:
    5
    We are experiencing this issue on our test Samsung S4 but not on an S5 nor S6. We are attempting to download assetbundles from an Amazon S3 bucket which uses a certificate "symantec class 3 secure server ca - g4" certificate. I read an article stating that Android should no longer trust this certificate as it was being retired. I'm not sure whether this could be the issue given that the more recent phones can connect using HTTPS to the S3 bucket without any problems.

    Any suggestions on how I can troubleshoot or debug this issue?
     
  9. bakno

    bakno

    Joined:
    Mar 18, 2007
    Posts:
    604
    You can debug the problem by visiting a page on the same domain using the Android browser. It will show you a certificate error.

    The way we ended up solving this problem was by editing the Intermediate Certificate, so instead of using any of the three CA certificates provided by Comodo, we concatenated all 3 certificates into a single one using a text editor.