Https 侦听器证书错误

Https Listener Certificate error

我做了以下事情: 我在所有步骤中都没有遇到错误,但现在如果我想连接到侦听器,我会收到以下错误:

  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

我做错了什么?

Edge 和 Chrome 都信任该证书,因为您将它放在 Windows 证书信任库中。他们都不喜欢它向 "localhost" 提供请求,因为您的证书似乎具有 vMargeBySignedCA 的主题 CN 值并且没有主题备用名称扩展。

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