Nico.E
Nico.E

Reputation: 82

Https Listener Certificate error

I did following Thing: httplistener-with-https-support I got no error through all steps but now if I want to connect to the listener, I get following Errors:

  1. From Chrome I get: "NET::ERR_CERT_COMMON_NAME_INVALID"
  2. From Edge I get: "DLG_FLAGS_SEC_CERT_CN_INVALID"
  3. From Firefox I get: "SEC_ERROR_UNKNOWN_ISSUER"

This is my Code:

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 are my certifications: HERE

What did I wrong?

Upvotes: 0

Views: 308

Answers (1)

bartonjs
bartonjs

Reputation: 33238

Both Edge and Chrome trust the cert because you put it in the Windows cert trust store. They both dislike it serving up requests to "localhost" because your certificate seems to have the subject CN value of vMargeBySignedCA and no Subject Alternative Name extension.

Firefox doesn't use the Windows trust store, so it doesn't trust the CA (you'd need to add it to Firefox's trust store). It reports the unknown issuer / untrusted cert prior to reporting that the name made no sense in context.

Upvotes: 1

Related Questions