Hello!
I’m using the WWW class to make some post request to an App Engine Server (https as you can see). When doing these request i get the following error (as stated in the title): “https://x.yyyyyy.appspot.com/”. I’m pretty sure this isn’t Unity specific, since it has to do with doing an SSL connection without a certificate or something like that (not really an expert in this field). But the odd thing is that this is working with other Android versions, just not 4.2.
When reading about possible solutions i only stumble upon ones where it is required to make use off other Http-libraries (modifying HostnameVerifier) where-as I would prefer a solution where i can use the WWW class, is this impossible?
Google App Engine specifics:
In the URL, the:
x = version number
y = the appname
By specifying the version number one can access a certain version of the server (duh!), but it is not necessary to do so to access the server. If I don’t provide the version number everything works as expected (and it will then use the latest version, but I really need to be able to access the server by version numbers).
Thank you!
EDIT: Using: Unity 3.5.7f6
EDIT: Solved. It appears that Google App Engine no longer support SSL certificates for the domains in the following format https://x.yyyy.appspot.com. Instead one should use the following format if they wish to use https. Example: https://x-dot-yyyy.appspot.com
This might help someone else (still not sure why this “error” doesn’t appear on other Android versions though!)
Hello
I have the same issue with this kind of website :
https://www.name.olympe.in/
I can’t use the x-dot- (it didn’t work to me).
Anyone know how can I resolve this issue?
I use the Server Side Highscore script :
using UnityEngine;
using System.Collections;
public class HSController : MonoBehaviour
{
private string secretKey = "mySecretKey"; // Edit this value and make sure it's the same as the one stored on the server
public string addScoreURL = "http://localhost/unity_test/addscore.php?"; //be sure to add a ? to your url
public string highscoreURL = "http://localhost/unity_test/display.php";
void Start()
{
StartCoroutine(GetScores());
}
// remember to use StartCoroutine when calling this function!
IEnumerator PostScores(string name, int score)
{
//This connects to a server side php script that will add the name and score to a MySQL DB.
// Supply it with a string representing the players name and the players score.
string hash = MD5Test.Md5Sum(name + score + secretKey);
string post_url = addScoreURL + "name=" + WWW.EscapeURL(name) + "&score=" + score + "&hash=" + hash;
// Post the URL to the site and create a download object to get the result.
WWW hs_post = new WWW(post_url);
yield return hs_post; // Wait until the download is done
if (hs_post.error != null)
{
print("There was an error posting the high score: " + hs_post.error);
}
}
// Get the scores from the MySQL DB to display in a GUIText.
// remember to use StartCoroutine when calling this function!
IEnumerator GetScores()
{
gameObject.guiText.text = "Loading Scores";
WWW hs_get = new WWW(highscoreURL);
yield return hs_get;
if (hs_get.error != null)
{
print("There was an error getting the high score: " + hs_get.error);
}
else
{
gameObject.guiText.text = hs_get.text; // this is a GUIText that will display the scores in game.
}
}
}
Thank for your help
The issue lies within the SSL certificate. The issue occurs inside WWW Class or more deep (to be correct) in Android’s handling (verifying) of SSL certificates. Android can’t verify that the given URL with one of the URLs provided by the SSL Certificate.
You can fix this by overriding verification in Java, but that ‘d require access to the WWW Class’ underlying Android implemenetation. (And is obviously not a fix for live environments!!)
Whysers solved his issue already.
If you want to verify the issue as described here: Security with network protocols | App quality | Android Developers
You can look for what hostnames the certificate is valid: openssl.exe s_client -connect appspot.com:443 | openssl x509 -text
Hope that helps additionally.