title: could not read from connection:remote error: tls: unknown certificate
body: <p>I'm creating a low level HTTP/2 server in Go and for testing I want to use a self-signed certificate. I'm using openssl and this command to generate my certs:</p>
  <p><code>openssl req -x509 -newkey rsa:4096 -nodes -sha256 -subj /CN=localhost -keyout private.pem -out cert.pem</code></p>
  <p>all seems well and when I <code>curl -kv https://127.0.0.1:443 --http2-prior-knowledge</code> I get  <a href="https://i.stack.imgur.com/S1G17.png" rel="nofollow noreferrer">this handshake</a></p>
  <p>When I try to connect with chrome I get this error code <code>NET::ERR_CERT_AUTHORITY_INVALID</code>, of course I choose to continue, but my servers exits the connection with this <code>could not read from connection:remote error: tls: unknown certificate</code>.</p>
  <p>I have tried making different certs but no luck. How can I have a TLS connection with my server and chrome?</p>
  <p>Here is how I setup tls:</p>
  <pre class="lang-golang prettyprint-override"><code>    cer, err := tls.LoadX509KeyPair(&quot;cert.pem&quot;, &quot;private.pem&quot;)
      if err != nil {
          log.Println(err)
          return
      }
  
      config := &amp;tls.Config{Certificates: []tls.Certificate{cer}}
      ln, err := tls.Listen(&quot;tcp&quot;, &quot;localhost:443&quot;, config) 
      if err != nil {
          log.Println(err)
          return
      }
      defer ln.Close()
  </code></pre>