title: Golang: how to specify certificate in TLS config for http client
body: <p>I have a cert file, that location is: <code>/usr/abc/my.crt</code> and I want to use that cert for my tls config, so that my http client uses that certificate when communicate with other servers. My current code is as follows:</p>
  
  <pre><code>mTLSConfig := &amp;tls.Config {
      CipherSuites: []uint16 {
          tls.TLS_RSA_WITH_RC4_128_SHA,
          tls.TLS_RSA_WITH_3DES_EDE_CBC_SHA,
          tls.TLS_RSA_WITH_AES_128_CBC_SHA,
          tls.TLS_ECDHE_RSA_WITH_RC4_128_SHA,
          tls.TLS_RSA_WITH_AES_128_CBC_SHA,
          tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,
      }
  }
  
  mTLSConfig.PreferServerCipherSuites = true
  mTLSConfig.MinVersion = tls.VersionTLS10
  mTLSConfig.MaxVersion = tls.VersionTLS10
  
  tr := &amp;http.Transport{
      TLSClientConfig: mTLSConfig,
  }
  
  c := &amp;http.Client{Transport: tr}
  </code></pre>
  
  <p>So how to assign a certificate in my TLS config? I see the certificate settings at <a href="http://golang.org/pkg/crypto/tls/#Config">http://golang.org/pkg/crypto/tls/#Config</a> can someone suggest how to config my cert location there?</p>
  
  <p><code>mTLSConfig.Config{Certificates: []tls.Certificate{'/usr/abc/my.crt'}}</code> &lt;-- is wrong because I am passing string.right? I DON'T have ANY other files such as .pem or .key etc, just only this my.cert. I am blank how to do it?</p>
  
  <p>Earlier, I had edited the go source code <a href="http://golang.org/src/pkg/crypto/x509/root_unix.go">http://golang.org/src/pkg/crypto/x509/root_unix.go</a>  and added <code>/usr/abc/my.crt</code> after line no. 12 and it worked. But the problem is my certificate file location can change, so I have removed the hardcoded line from root_unix.go and trying to pass it dynamically, when building TLSConfig.</p>