Mono - HttpWebRequest over SSL - Error writing hea

2019-04-29 06:13发布

问题:

The below throws a System.Net.WebException - Error:SendFailure (Error writing headers) over SSL but works fine for http://www.google.com

using System;
using System.Web;
using System.Net;
using System.IO;

namespace HTTPS_Headers
{
    class MainClass
    {
        public static void Main (string[] args)
        {
            var request = (HttpWebRequest)WebRequest.Create ("https://www.google.co.uk/?q=mono");

            using(var reader = new StreamReader(request.GetResponse().GetResponseStream())) {

                Console.WriteLine (reader.ReadToEnd ());
            }

            Console.ReadLine();
        }
    }
}

I am running this on Mono 3.4.0/Lubuntu 14.04. Works fine over SSL on Windows/.NET 4.

回答1:

Try running the following on your machine to import trusted root certificates:

mozroots --import --sync


标签: mono