I have an application that has been working fine using Unity’s WWW object.
A client is looking for a build that will work with their proxy so the WWW object will no longer do.
I’m not too worried about the proxy part, I assume that will be fine once I get HttpWebRequest or WebClient or something along those lines to work.
This is my sandbox web connection at the moment.
public void ExecuteWebConnection()
{
ServicePointManager.ServerCertificateValidationCallback += Validator;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
request.ContentType = "application/x-www-form-urlencoded";
request.Method = "POST";
byte[] postBytes = Encoding.ASCII.GetBytes("action=testconnection");
Stream requestStream = request.GetRequestStream();
requestStream.Write(postBytes, 0, postBytes.Length);
requestStream.Close();
// grab te response and print it out to the console along with the status code
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
userMessage.text = new StreamReader(response.GetResponseStream()).ReadToEnd();
Debug.Log(response.StatusCode.ToString());
}
public static bool Validator (object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
return true; // for testing
}
This all works fine on a local vm without https and will also work online if I enable Ssl3 to test this.
But that is the problem. Ssl3 is not an option for security reasons. We only have Tls1.2 enabled.
It seems tls1.2 support is coming in Unity2018.1 but this can’t wait unfortunately.
WebException: Error writing request: The authentication or decryption has failed.
System.Net.WebConnectionStream.WriteHeaders ()
System.Net.WebConnectionStream.SetHeaders (System.Byte[] buffer)
(wrapper remoting-invoke-with-check) System.Net.WebConnectionStream:SetHeaders (byte[])
System.Net.HttpWebRequest.SendRequestHeaders (Boolean propagate_error)
UnityEngine.EventSystems.EventSystem:Update()
I’ve looked at many posts relating to this but most seem to point to FAQ: Security | Mono
I don’t know much about Ssl, tls or certs but I don’t think the problem is with access to the cert as it works fine when I enable Ssl3 on the server but it never even reaches the Validator function when it fails.
Any ideas?