I am developing a WEBGL app which needs to interact with a REST API via https where the server certificate is untrusted. Since I cannot use System.Net on WebGL I tried to use the new UnityWebRequest but I found nothing where to handle certificates.
In System.Net I would do something like this:
ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, errors) => true;
When I try a simple “POST” I always get “Unknown Error” and responseCode == 0;
IEnumerator Authentification()
{
var fu = @"{""data1"": ""fudata"",""data2"": ""fudata2""}";
byte[] payload = new byte[fu.Length * sizeof(char)];
System.Buffer.BlockCopy(fu.ToCharArray(),0,payload,0, payload.Length);
UploadHandler upload = new UploadHandlerRaw(payload);
upload.contentType = "application/json";
UnityWebRequest request = new UnityWebRequest("https://someSide.com/PostRequest");
request.uploadHandler = upload;
yield return request.Send();
if(request.isError)
{
Debug.Log(request.error + request.errorCode);
}
else
{
Debug.Log(request.downloadHandler.text);
}
}
If something like this is not possible, is there some kind of workaround?