- Home /
Question by
ZachAttack9280 · Apr 07, 2018 at 10:21 PM ·
c#errorexceptiondownloadingwebclient
TlsException error only on windows 10 (not mac)
Hello, I have made a script where I can download the price of bitcoin from an api source. This script only works on one of my windows 10 desktops and my macbook air. For some strange reason i get this really long and strange error on my second desktop during the download process (i think). Here is the error:
TlsException: Invalid certificate received from server. Error code: 0xffffffff80092012
Mono.Security.Protocol.Tls.Handshake.Client.TlsServerCertificate.validateCertificates (Mono.Security.X509.X509CertificateCollection certificates)
Mono.Security.Protocol.Tls.Handshake.Client.TlsServerCertificate.ProcessAsTls1 ()
Mono.Security.Protocol.Tls.Handshake.HandshakeMessage.Process ()
(wrapper remoting-invoke-with-check) Mono.Security.Protocol.Tls.Handshake.HandshakeMessage:Process ()
Mono.Security.Protocol.Tls.ClientRecordProtocol.ProcessHandshakeMessage (Mono.Security.Protocol.Tls.TlsStream handMsg)
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)
Here is the script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System.Linq;
using System.Text;
using System.Net;
using System;
public class EthereumPrice : MonoBehaviour {
public Text ethPriceText;
public Text updateText;
public float updateTime = 30;
public float time = 0;
public float ethPriceR;
public GameObject priceUpdatePopUp;
public void Start() {
StartCoroutine(Example());
priceUpdatePopUp.SetActive(false);
}
public void Update() {
time += Time.deltaTime;
updateTime -= Time.deltaTime;
updateText.text = "Price Update in " + updateTime.ToString("F0") + " seconds. (Lags)";
priceUpdatePopUp.SetActive(false);
if (time >= 30) {
StartCoroutine(Example());
time = 0;
}
if (updateTime <= 0)
{
updateTime = 30;
}
}
IEnumerator Example()
{
yield return new WaitForSecondsRealtime(1f);
using (WebClient webClient = new System.Net.WebClient())
{
priceUpdatePopUp.SetActive(true);
WebClient n = new WebClient();
var json = n.DownloadString("https://min-api.cryptocompare.com/data/price?fsym=ETH&tsyms=USD");
string valueOriginal = Convert.ToString(json);
json = json.Replace("{\"USD\":", string.Empty);
json = json.Replace("}", string.Empty);
var sStrings = json.Split();
float ethPrice = float.Parse(sStrings[0]);
ethPriceR = ethPrice;
ethPriceText.text = "Ethereum ($" + ethPrice + ")";
time += Time.deltaTime;
Debug.Log(json);
}
}
}
Any suggestions? Fast replies would be nice but not necessary.
Comment
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
I'm getting a StackOverFlowException 1 Answer
Distribute terrain in zones 3 Answers
Best way to handle exceptions in release 1 Answer
Despawner script returns null reference exception. 0 Answers