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

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.

If you want to use Unity WWW class, then get a certificate issued by a well known CA.

Otherwise there might be an Android plugin that does https with self signed certificates, but I haven’t checked out the situation.

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.

Actually, it’s not working with a well known CA either, we tried that and I get the exact same error on Android.

Then you should do a bug report for that.

Any news?
We have such problems too.

Was this solved?

We are having the same problem.

Please help!

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?

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.