Created
July 5, 2016 15:04
-
-
Save Gobonoid/942de5cdba425e35e25cba270d5894a2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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