Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

UnityWebRequest Certificate Handler causes "Unknown Error"

Discussion in 'Editor & General Support' started by sgt3v, Oct 24, 2019.

  1. sgt3v

    sgt3v

    Joined:
    Feb 19, 2017
    Posts:
    28
    I want to validate the certificate of the response of web requests I make from UnityWebRequest. Without certificateHandler line it gets job done and works just right. When I add the line 8 it returns network error, which is called "Unknown Error". Is this a bug, or am I missing something?

    Code (CSharp):
    1.  
    2. public class WebRequest
    3. {
    4.   using (UnityWebRequest request = new UnityWebRequest("https://www.url.com/list", "POST"))
    5.   {
    6.     request.uploadHandler = new UploadHandlerRaw(someData);
    7.     request.downloadHandler = new DownloadHandlerBuffer();
    8.  
    9.     //problem line
    10.     request.certificateHandler = new RequestCertificate();
    11.  
    12.     yield return request.SendWebRequest();
    13.  
    14.     Debug.Log(request.error);
    15.   }
    16. }
    17. ...
    18.  
    19. internal class RequestCertificate : CertificateHandler
    20. {
    21.   protected override bool ValidateCertificate(byte[] certificateData)
    22.   {
    23.     return true;
    24.   }
    25. }
    26.  
     
  2. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,637
    Looks like a bug. Is you certificate handler actually this - a trust all one?
    And also, which platform is this on?
     
  3. sgt3v

    sgt3v

    Joined:
    Feb 19, 2017
    Posts:
    28
    Yes using this exact code I run - except for the url and someData var. Code does not even enter the breakpoint at return true line in the Validatecert method.

    2018.3.14f1, in Editor, Windows 10
     
  4. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,637
    Please, report a bug.
    Thanks.
     
    sgt3v likes this.