remove spaces, change msg

This commit is contained in:
Christoph Schuler 2017-01-20 10:50:33 +01:00
parent 6ee72ddb09
commit 2b01f7f603
2 changed files with 2 additions and 12 deletions

@ -24,25 +24,18 @@ func isCertVerificationDisabledForHost(c *Client, host string) bool {
// isClientCertEnabledForHost returns whether client certificate
// are configured for the given host
func isClientCertEnabledForHost(c *Client, host string) bool {
_, hostSslKeyOk := c.gitEnv.Get(fmt.Sprintf("http.https://%v/.sslKey", host))
_, hostSslCertOk := c.gitEnv.Get(fmt.Sprintf("http.https://%v/.sslCert", host))
_, hostSslCaInfoOk := c.gitEnv.Get(fmt.Sprintf("http.https://%v/.sslCaInfo", host))
if hostSslKeyOk && hostSslCertOk && hostSslCaInfoOk {
return true
}
return false
return hostSslKeyOk && hostSslCertOk && hostSslCaInfoOk
}
// getClientCertForHost returns a client certificate for a specific host (which may
// be "host:port" loaded from the gitconfig
func getClientCertForHost(c *Client, host string) tls.Certificate {
hostSslKey, _ := c.gitEnv.Get(fmt.Sprintf("http.https://%v/.sslKey", host))
hostSslCert, _ := c.gitEnv.Get(fmt.Sprintf("http.https://%v/.sslCert", host))
cert, err := tls.LoadX509KeyPair(hostSslCert, hostSslKey)
if err != nil {
tracerx.Printf("Error reading client cert/key %v", err)

@ -167,12 +167,9 @@ func (c *Client) httpClient(host string) *http.Client {
tr.TLSClientConfig = &tls.Config{}
if isClientCertEnabledForHost(c, host) {
tracerx.Printf("using certs ...")
tracerx.Printf("http: client cert for %s", host)
tr.TLSClientConfig.Certificates = []tls.Certificate{getClientCertForHost(c, host)}
tr.TLSClientConfig.BuildNameToCertificate()
}
if isCertVerificationDisabledForHost(c, host) {