1

I'm playing with Runscope using Mono 3 on the Mac. Using the code below I'm getting an exception:

System.Net.WebException: Error getting response stream (Write: The authentication or decryption has failed.): SendFailure ---> System.IO.IOException: The authentication or decryption has failed. ---> Mono.Security.Protocol.Tls.TlsException: The authentication or decryption has failed.

I don't understand why, as the ServicePointManager.ServerCertificateValidationCallback should effectively approve all certificates.

Also note that the code works perfectly under Visual Studio on Windows.

Any ideas?

class Program
    {
        private static Uri url = new Uri("https://api-github-com-[MY_PERSONAL_TOKEN_HERE].runscope.net/");

        static void Main(string[] args)
        {
            ServicePointManager.ServerCertificateValidationCallback +=
                (sender, cert, chain, sslPolicyErrors) => true;
            MakeRequest();
            Console.ReadKey ();
        }

        private static async Task MakeRequest()
        {
            try
            {
            var httpClient = new HttpClient();
            var response = await httpClient.GetAsync(url);
            var body = await response.Content.ReadAsStringAsync();
            Console.WriteLine("Body: " + body);
            }
            catch(Exception ex)
            {
                Console.WriteLine (ex);
            }
        }
    }
Krumelur
  • 32,180
  • 27
  • 124
  • 263
  • As an aside, the license on HttpClient prevents you from using it on Mono. See http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/4494577-remove-the-platform-restriction-on-microsoft-nuget – Darrel Miller Nov 09 '13 at 14:49
  • This seems related to Mono and our wildcard cert. Adding just runscope.net to the trusted store seems to work fine `certmgr -ssl runscope.net` but adding a subdomain breaks it. We're investigating to see if we can make any changes to the cert to get it to work. – John Sheehan Nov 09 '13 at 21:18
  • @RunscopeAPITools Does not work for me her on the Mac. I had to use `certmgr -ssl https://runscope.net` but I still get the same exception, both for Mono console and iOS. – Krumelur Nov 10 '13 at 09:08
  • @Darrel FYI. It seems Microsoft lifted the windows-only license restrictions for HttpClient and other NuGet packages! :) ...coincidentily, about 4 days after you posted. Visit your link again for details. – guru_florida Mar 19 '14 at 15:29
  • @guru_florida I like to pretend that my link pointing to the uservoice site garnered sufficient votes to tip the balance in favour of the changing the licence ;-) – Darrel Miller Mar 19 '14 at 15:32

0 Answers0