Skip to content

Instantly share code, notes, and snippets.

@Gobonoid
Created July 5, 2016 15:04
Show Gist options
  • Save Gobonoid/942de5cdba425e35e25cba270d5894a2 to your computer and use it in GitHub Desktop.
Save Gobonoid/942de5cdba425e35e25cba270d5894a2 to your computer and use it in GitHub Desktop.
func getCertAPIClient(certificatePath string, debug bool) (*http.Client, error) {
certs := x509.NewCertPool()
pemData, err := ioutil.ReadFile(certificatePath)
if err != nil {
return nil, err
}
conn, err := tls.Dial("tcp", "certapi.t2.nectar.com:443", &tls.Config{
RootCAs: certs,
InsecureSkipVerify: debug,
})
if err != nil {
panic(err)
}
certs.AppendCertsFromPEM(pemData)
tr := &http.Transport{TLSClientConfig: &tls.Config{
RootCAs: certs,
InsecureSkipVerify: debug,
}}
return &http.Client{
Transport: tr,
}, nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment