Skip to content

Instantly share code, notes, and snippets.

@JamieAP
Last active January 18, 2018 14:03
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save JamieAP/24325d34d4d6cafbef6ffefd835a1063 to your computer and use it in GitHub Desktop.
clientCertPool := x509.NewCertPool()
clientCertPool.AddCert(config.Certificate)
cert := tls.Certificate{
Certificate: clientCertPool.Subjects(),
PrivateKey: config.PrivateKey,
}
tlsConfig := &tls.Config{
GetClientCertificate: func(info *tls.CertificateRequestInfo) (*tls.Certificate, error) {
return &cert, nil
},
ClientAuth: tls.RequireAndVerifyClientCert,
ClientCAs: clientCertPool,
MinVersion: tls.VersionTLS12,
InsecureSkipVerify: true,
Renegotiation: tls.RenegotiateFreelyAsClient,
}
tlsConfig.BuildNameToCertificate()
transport := &http.Transport{
TLSClientConfig: tlsConfig,
TLSHandshakeTimeout: time.Second * 10,
}
client := &http.Client{
Transport: transport,
Timeout: time.Second * time.Duration(config.TimeoutSecs),
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment