Https侦听器证书错误

时间:2018-07-13 14:12:09

标签: .net x509certificate httplistener

我遵循了以下规定: httplistener-with-https-support 我所有步骤都没有错误,但是现在如果我想连接到侦听器,则会出现以下错误:

  1. 从Chrome浏览器中,我得到:“ NET :: ERR_CERT_COMMON_NAME_INVALID”
  2. 从Edge我得到:“ DLG_FLAGS_SEC_CERT_CN_INVALID”
  3. 从Firefox中,我得到:“ SEC_ERROR_UNKNOWN_ISSUER”

这是我的代码:

static void Main(string[] args)
    {
        var prefixes = "https://*:8080/";
        var listener = new HttpListener();
            listener.Prefixes.Add(prefixes);
        listener.Start();
        Console.WriteLine("Listening...");

        HttpListenerContext context = listener.GetContext();
        HttpListenerRequest request = context.Request;
        // Obtain a response object.
        HttpListenerResponse response = context.Response;
        // Construct a response.
        string responseString = "<HTML><BODY> Hello world!</BODY></HTML>";
        byte[] buffer = System.Text.Encoding.UTF8.GetBytes(responseString);
        // Get a response stream and write the response to it.
        response.ContentLength64 = buffer.Length;
        System.IO.Stream output = response.OutputStream;
        output.Write(buffer, 0, buffer.Length);
        // You must close the output stream.
        Console.ReadKey();
        output.Close();
        listener.Stop();

这是我的认证:HERE

我怎么了?

1 个答案:

答案 0 :(得分:1)

Edge和Chrome都信任该证书,因为您将其放入Windows证书信任存储区中。他们俩都不喜欢它向“ localhost”提供请求,因为您的证书的主题CN值似乎为vMargeBySignedCA,并且没有主题替代名称扩展名。

Firefox不使用Windows信任库,因此它不信任CA(您需要将其添加到Firefox的信任库中)。在报告名称在上下文中没有任何意义之前,它将报告未知的发行者/不受信任的证书。