Hi,
I’m trying to write some code to download a binary file from Azure Storage (blob). I’ve grabbed the certificate and added this to the resources as mentioned in the TLS sample code:
var certificates = TyranntResources.GetBytes(TyranntResources.BinaryResources.msstoragecert);
X509Certificate[] certx509 = new X509Certificate[] { new X509Certificate(certificates) };
int read = 0, total = 0;
byte[] result = new byte[512];
string resultString = "";
try
{
using (var req = HttpWebRequest.Create(url) as HttpWebRequest)
{
req.Method = "GET";
req.KeepAlive = false;
req.HttpsAuthentCerts = certx509;
req.ReadWriteTimeout = 2000;
using (var res = req.GetResponse() as HttpWebResponse)
When it runs the GetResponse, I get the following exception:
#### Exception System.InvalidOperationException - CLR_E_INVALID_OPERATION (1) ####
#### Message:
#### GHIElectronics.TinyCLR.Devices.Network.Provider.NetworkControllerApiWrapper::AuthenticateAsClient [IP: 0000] ####
#### System.Net.Security.SslStream::AuthenticateAsClient [IP: 0016] ####
#### System.Net.Security.SslStream::AuthenticateAsClient [IP: 0009] ####
#### System.Net.Security.SslStream::AuthenticateAsClient [IP: 0008] ####
#### System.Net.HttpWebRequest::EstablishConnection [IP: 0251] ####
#### System.Net.HttpWebRequest::SubmitRequest [IP: 0019] ####
#### System.Net.HttpWebRequest::GetResponse [IP: 000c] ####
#### TyranntIot.Io.NetworkIo::HTTPGETString [IP: 005b] ####
#### TyranntIot.Game.Setup::GetIcon [IP: 0009] ####
#### TyranntIot.Program::Main [IP: 013f] ####
#### Exception System.Net.WebException - 0x00000000 (1) ####
#### Message:
#### System.Net.HttpWebRequest::GetResponse [IP: 00d3] ####
#### TyranntIot.Io.NetworkIo::HTTPGETString [IP: 005b] ####
#### TyranntIot.Game.Setup::GetIcon [IP: 0009] ####
#### TyranntIot.Program::Main [IP: 013f] ####
Exception thrown: ‘System.Net.WebException’ in GHIElectronics.TinyCLR.Networking.Http.dll
I’m assuming that I’ve mucked up something with the certificate. Any ideas?
Thanks,
Jas