diff --git a/AssemblyInfo.cs b/AssemblyInfo.cs index 89dae49..1dc2c6b 100644 --- a/AssemblyInfo.cs +++ b/AssemblyInfo.cs @@ -2,6 +2,7 @@ using System.Runtime.InteropServices; using System.Runtime.Serialization; +#if !(UNITY_5_0 || UNITY_4_6 || UNITY_4_5 || UNITY_4_3 || UNITY_4_2 || UNITY_4_1 ) // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. @@ -35,3 +36,4 @@ // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("0.0.0.0")] [assembly: AssemblyFileVersion("0.0.0.0")] +#endif \ No newline at end of file diff --git a/lib/JSON.cs b/lib/JSON.cs index ae06abd..ea9683d 100644 --- a/lib/JSON.cs +++ b/lib/JSON.cs @@ -241,8 +241,12 @@ protected static string ParseString (char[] json, ref int index, ref bool succes if (!(success = UInt32.TryParse (new string (json, index, 4), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out codePoint))) { return ""; } - // convert the integer codepoint to a unicode char and add to string - s.Append (Char.ConvertFromUtf32 ((int)codePoint)); + try{ + // convert the integer codepoint to a unicode char and add to string + s.Append (Char.ConvertFromUtf32 ((int)codePoint)); + }catch(Exception e){ + s.Append ( "" ); + } // skip 4 chars index += 4; } else { diff --git a/src/Request.cs b/src/Request.cs index c9b358d..24d581c 100644 --- a/src/Request.cs +++ b/src/Request.cs @@ -24,6 +24,23 @@ public enum RequestState { Waiting, Reading, Done } + public class CertVerifier + { + public delegate bool CertVerifierCB (object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors); + + public static CertVerifierCB verifier = new CertVerifierCB(DefaultServerCertificateValidator); + + public static bool DefaultServerCertificateValidator (object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) + { + #if !UNITY_EDITOR + System.Console.WriteLine( "NET: SSL Cert: " + sslPolicyErrors.ToString() ); + #else + Debug.LogWarning("SSL Cert Error: " + sslPolicyErrors.ToString ()); + #endif + return true; + } + } + public class Request { public static bool LogAllRequests = false; @@ -77,7 +94,7 @@ public Request( string method, string uri, WWWForm form ) this.method = method; this.uri = new Uri (uri); this.bytes = form.data; - foreach ( DictionaryEntry entry in form.headers ) + foreach ( var entry in form.headers ) { this.AddHeader( (string)entry.Key, (string)entry.Value ); } @@ -160,7 +177,7 @@ private void GetResponse() { using (var stream = client.GetStream ()) { var ostream = stream as Stream; if (uri.Scheme.ToLower() == "https") { - ostream = new SslStream (stream, false, new RemoteCertificateValidationCallback (ValidateServerCertificate)); + ostream = new SslStream (stream, false, new RemoteCertificateValidationCallback (CertVerifier.verifier)); try { var ssl = ostream as SslStream; ssl.AuthenticateAsClient (uri.Host); @@ -301,16 +318,6 @@ public string Text { set { bytes = System.Text.Encoding.UTF8.GetBytes (value); } } - public static bool ValidateServerCertificate (object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) - { -#if !UNITY_EDITOR - System.Console.WriteLine( "NET: SSL Cert: " + sslPolicyErrors.ToString() ); -#else - Debug.LogWarning("SSL Cert Error: " + sslPolicyErrors.ToString ()); -#endif - return true; - } - void WriteToStream( Stream outputStream ) { var stream = new BinaryWriter( outputStream );