title: ListenAndServerTLS keeps failing with error: failed to find any PEM data in certificate input
body: <p>I bought an SSL certificate from Godaddy for a web site.
  I added the files in the server and run the service and it just returns an error:</p>
  
  <blockquote>
    <p>failed to find any PEM data in certificate input</p>
  </blockquote>
  
  <p>I used cat to generate a server.pem file with all the files, even added a godaddy pem intermediate pem file they provide for a G2 Certificate Chain and nothing.</p>
  
  <pre class="lang-bsh prettyprint-override"><code>cat generated-private-key.txt &gt; server.pem
  cat 678f65b8a7391017.crt &gt;&gt; server.pem
  cat gd_bundle-g2-g1.crt &gt;&gt; server.pem
  cat gdig2.crt.pem &gt;&gt; server.pem
  </code></pre>
  
  <p>Using self signed certificate works but off course it's not usable in real world.</p>
  
  <p>Code attempt 1:</p>
  
  <pre class="lang-golang prettyprint-override"><code>log.Fatal(http.ListenAndServeTLS(fmt.Sprintf("%s:%d", configuration.HttpServer.Address, configuration.HttpServer.Port), "server.pem", "generated-private-key.txt", router))
  </code></pre>
  
  <p>Code attempt 2:</p>
  
  <pre class="lang-golang prettyprint-override"><code>    cert, err := tls.LoadX509KeyPair("server.pem","generated-private-key.txt")
      if err != nil {
          log.Fatalf("server: loadkeys: %s", err)
      }
      pem, err := ioutil.ReadFile("gd_bundle-g2-g1.crt")
      if err != nil {
          log.Fatalf("Failed to read client certificate authority: %v", err)
      }
      certpool := x509.NewCertPool()
      if !certpool.AppendCertsFromPEM(pem) {
          log.Fatalf("Can't parse client certificate authority")
      }
      tlsConfig := &amp;tls.Config{
          ClientCAs:    certpool,
          Certificates: []tls.Certificate{cert},
      }
  
      srv := &amp;http.Server{
          Addr: fmt.Sprintf("%s:%d", configuration.HttpServer.Address, configuration.HttpServer.Port),
          Handler: router,
          ReadTimeout: time.Duration(5) * time.Second,
          WriteTimeout: time.Duration(5) * time.Second,
          TLSConfig: tlsConfig,
      }
      log.Fatal(srv.ListenAndServeTLS("678f65b8a7391017.crt","generated-private-key.txt"))
  </code></pre>
  
  <p>Both give the same error.</p>
  
  <p>I need to have this up and running as I already have the back-end done but now I just want to enable HTTPS for productive environment.</p>