Search Unity

WebClient throwing TlsException Unity 2017.4.15f1

Discussion in 'Scripting' started by millefoliumink, Dec 10, 2018.

  1. millefoliumink

    millefoliumink

    Joined:
    Aug 28, 2014
    Posts:
    139
    This piece of code is throwing a TlsException in Unity 2017.4.15f1, I've looked at other questions but no solution appears to work anymore. I vaguely understand this is an issue around certificates(?)

    Code (CSharp):
    1.         private void Start()
    2.     {
    3.         var client = new WebClient();
    4.         var text = client.DownloadString("https://jsonplaceholder.typicode.com/posts/1");
    5.         Debug.Log(text);
    6.     }

    // --- ERROR THROWN

    TlsException: The authentication or decryption has failed.
    Mono.Security.Protocol.Tls.RecordProtocol.ProcessAlert (AlertLevel
    alertLevel, AlertDescription alertDesc)
    Mono.Security.Protocol.Tls.RecordProtocol.InternalReceiveRecordCallback
    (IAsyncResult asyncResult)
    Rethrow as IOException: The authentication or decryption has failed.
    Mono.Security.Protocol.Tls.SslStreamBase.AsyncHandshakeCallback
    (IAsyncResult asyncResult)
    Rethrow as WebException: Error getting response stream (Write: The
    authentication or decryption has failed.): SendFailure
    System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult)
    System.Net.HttpWebRequest.GetResponse ()
    System.Net.WebClient.GetWebResponse (System.Net.WebRequest request)
    System.Net.WebClient.DownloadDataCore (System.Uri address, System.Object userToken)