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

Question How to create custom CertificateHandler, which uses the base handler inside itself?

Discussion in 'Scripting' started by iluxa_1810, Jul 13, 2023.

  1. iluxa_1810

    iluxa_1810

    Joined:
    Jul 13, 2023
    Posts:
    4
    In general, some users get this kind of error:

    Webrequest fails with Curl error 60, when is created UnityWebRequest.

    I would like to make my own CertificateHandler, which calls the base CertificateHandler inside itself (that is, the system first tried to resolve everything) and if it didn’t work out, then the additional logic of my handler came into play.

    I had an option to add my Handler after an error (that is, first we don’t assign anything to the handler property), but I don’t understand how to catch this particular error.

    She seems to have no code, and there is only the text SSL CA certificate error. And it’s probably not good to navigate only by text, since it changes from system to system ...

    Should I use the X509 circuit?
    If so, with what parameters does UnityWebRequest check the certificate if handler = null ?
     
  2. KillDashNine

    KillDashNine

    Joined:
    Apr 19, 2020
    Posts:
    449
    I hope you understand what SSL certificates are and what this issue is related to. It means you are making a HTTPS request to a web URL (using cURL library under the hood) and your authentication is failing. I believe Curl error 60 means that you have configured your SSL connection to use self-signed certificates, and the cURL client doesn't find this certificate.

    When your game makes connections over the internet, you need to deal with the issue of network security, and use of self-signed certificates is suitable only for situations where you don't need security and you're not worried that some hacker would steal your connection.

    I will just point you to some text about self-signed certificates.

    https://security.stackexchange.com/...of-using-a-self-signed-certificate-for-a-game
     
  3. iluxa_1810

    iluxa_1810

    Joined:
    Jul 13, 2023
    Posts:
    4
    Why does not every user receive an error, but selectively?
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,563
    I had this on my website... turned out that one of the parent certificates in the trust chains "above me" had expired and success depended upon OTHER alternate trust chains existing on the computer.

    Which trust chains any computer comes with is a function of things far beyond my immediate experience, but my IT dude seemed to think that was the difference.

    This was the checker he pointed me to that showed the faulty cert:

    https://www.sslshopper.com/ssl-checker.html

    The errors were both random and consistent: if computer X failed or succeeded, it would always fail or succeed.
     
  5. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,632
    In case of UnityWebRequest it's either default handling or custom.
     
  6. iluxa_1810

    iluxa_1810

    Joined:
    Jul 13, 2023
    Posts:
    4
    Is there any way I can get the default renderer and call it in my handler?

    What parameters does the default handler have?

    If I do so:

    Code (CSharp):
    1. var certificate = new X509Certificate2(certificateData);
    2.  
    3. // Use the system default certificate validation
    4. var chain = new X509Chain();
    5. chain.ChainPolicy.RevocationMode = X509RevocationMode.NoCheck;
    6. chain.ChainPolicy.RevocationFlag = X509RevocationFlag.ExcludeRoot;
    7. chain.ChainPolicy.VerificationFlags = X509VerificationFlags.AllowUnknownCertificateAuthority;
    8.  
    9. if (chain.Build(certificate))
    10. {
    11.    return true;
    12. }
    It check = default handler ?
     
    Last edited: Jul 14, 2023
  7. iluxa_1810

    iluxa_1810

    Joined:
    Jul 13, 2023
    Posts:
    4
  8. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,632
    No, it's integral part of the system. It is exclusively either default handling or your, no support cascading/fallback. If use custom handler, you have to do all the handing yourself.