- Home /
Unity3d HTTPS Get with X509Certificate P12
Hi i want to do a http get attaching a X509Certificate P12 that i load from a file in the storage. The code i attached WORKS well in pure mono and c#, but in unity i got this problem:
NotSupportedException: Undefined length encoding. Mono.Security.ASN1..ctor (System.Byte[] data) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/Mono.Security/ASN1.cs:82) Mono.Security.X509.X509Certificate.Parse (System.Byte[] data) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/Mono.Security.X509/X509Certificate.cs:109) Rethrow as CryptographicException: Input data cannot be coded as a valid certificate.
The code is:
X509Certificate cert = new X509Certificate(@"D:\temp\cert.p12", "password");
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
webRequest.Method = "GET";
webRequest.Accept = "Application/xml";
webRequest.ClientCertificates.Add(cert);
HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse();
Debug.LogWarning("RESPONSE: " + webResponse.GetResponseStream());
I'm using Unity version 4.3.4f1, i tried it too in 4.6.3 and unity 5.0.1.
Your answer
Follow this Question
Related Questions
Why can't I access the constructor: X509Certificate2 (Byte[], String) on Web platform? 2 Answers
Is there a way to notify to the app once client has connected to server? 2 Answers
Master / Client - When to close connection ? 1 Answer
How to secure (encrypt) tcp client server connection? 1 Answer
Server question on windows 1 Answer