Hi everybody,
I’m trying to access data on a TheThingsNetwork server via HttpWebRequest. All works fine in a simple C# command line application.
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(urlIoTSensorData);
request.AutomaticDecompression = DecompressionMethods.GZip;
request.Headers["Authorization"] = "key ttn-account-v2.mqAaM7T6m58sqvdrgvqerp7h3nuO0LiX49XdH-CZsQ";
(I altered the key posted here obviously)
When I use the same code in Unity, I get: Error getting response stream (Write: The authentication or decryption has failed.): SendFailure
After some Googling, I found a workaround, which is to completely ignore the certificates issues:
System.Net.ServicePointManager.ServerCertificateValidationCallback +=
delegate (object sender, System.Security.Cryptography.X509Certificates.X509Certificate certificate,
System.Security.Cryptography.X509Certificates.X509Chain chain,
System.Net.Security.SslPolicyErrors sslPolicyErrors)
{
return true; // **** Always accept
};
Since I’m building for Hololens (UWP), I’m stuck with .NET Core, which doens’t have a ServicePointManager class. So I switched my scripting backend to IL2CPP.
All works great in Unity editor. I can build my project and put it on my Hololens via Visual Studio. But on the Hololens, at runtime, I get an error message: unable to load dll advapi32.dll.
So any pointers on this?
Is there a way to use HTTPWebRequest on the Hololens without the ugly ServicePointManager solution?
Is there a fix for the missing advapi32.dll error?
Thanks in advance,
Boi