Don't decode the certificates everytime we create an AppClient.

This commit is contained in:
Tom Wilkie
2015-12-09 17:44:47 +00:00
parent cde5920f9a
commit 9cff5699cb

View File

@@ -2,6 +2,7 @@ package xfer
import (
"crypto/tls"
"crypto/x509"
"fmt"
"io"
"net"
@@ -14,6 +15,16 @@ import (
// ID is currently set to the a random string on probe startup.
const ScopeProbeIDHeader = "X-Scope-Probe-ID"
var certPool *x509.CertPool
func init() {
var err error
certPool, err = gocertifi.CACerts()
if err != nil {
panic(err)
}
}
// ProbeConfig contains all the info needed for a probe to do HTTP requests
type ProbeConfig struct {
Token string
@@ -46,10 +57,6 @@ func (pc ProbeConfig) getHTTPTransport(hostname string) (*http.Transport, error)
return nil, err
}
certPool, err := gocertifi.CACerts()
if err != nil {
return nil, err
}
return &http.Transport{
TLSClientConfig: &tls.Config{
RootCAs: certPool,