func (c *Config) ConfigureTLS() error {
	if c.HTTPClient == nil {
		return fmt.Errorf("config HTTP Client must be set")
	}

	var clientCert tls.Certificate
	foundClientCert := false
	if c.TLSConfig.ClientCert != "" || c.TLSConfig.ClientKey != "" {
		if c.TLSConfig.ClientCert != "" && c.TLSConfig.ClientKey != "" {
			var err error
			clientCert, err = tls.LoadX509KeyPair(c.TLSConfig.ClientCert, c.TLSConfig.ClientKey)
			if err != nil {
				return err
			}
			foundClientCert = true
		} else {
			return fmt.Errorf("Both client cert and client key must be provided")
		}
	}

	clientTLSConfig := c.HTTPClient.Transport.(*http.Transport).TLSClientConfig
	rootConfig := &rootcerts.Config{
		CAFile: c.TLSConfig.CACert,
		CAPath: c.TLSConfig.CAPath,
	}
	if err := rootcerts.ConfigureTLS(clientTLSConfig, rootConfig); err != nil {
		return err
	}

	clientTLSConfig.InsecureSkipVerify = c.TLSConfig.Insecure

	if foundClientCert {
		clientTLSConfig.Certificates = []tls.Certificate{clientCert}
	}
	if c.TLSConfig.TLSServerName != "" {
		clientTLSConfig.ServerName = c.TLSConfig.TLSServerName
	}

	return nil
}
// ConfigureTLS applies a set of TLS configurations to the the HTTP client.
ConfigureTLS applies a set of TLS configurations to the the HTTP client.
// ConfigureTLS applies a set of TLS configurations to the the HTTP client .
func (c *Config) ConfigureTLS() error {
	if c.HTTPClient == nil {
		return fmt.Errorf("config HTTP Client must be set")
	}
	var clientCert tls.Certificate
	foundClientCert := false
	if c.TLSConfig.ClientCert != "" || c.TLSConfig.ClientKey != "" {
		if c.TLSConfig.ClientCert != "" && c.TLSConfig.ClientKey != "" {
			var err error
			clientCert, err = tls.LoadX509KeyPair(c.TLSConfig.ClientCert, c.TLSConfig.ClientKey)
			if err != nil {
				return err
			}
			foundClientCert = true
		} else {
			return fmt.Errorf("Both client cert and client key must be provided")
		}
	}
	clientTLSConfig := c.HTTPClient.Transport.(*http.Transport).TLSClientConfig
	rootConfig := &rootcerts.Config{
		CAFile: c.TLSConfig.CACert,
		CAPath: c.TLSConfig.CAPath,
	}
	if err := rootcerts.ConfigureTLS(clientTLSConfig, rootConfig); err != nil {
		return err
	}
	clientTLSConfig.InsecureSkipVerify = c.TLSConfig.Insecure
	if foundClientCert {
		clientTLSConfig.Certificates = []tls.Certificate{clientCert}
	}
	if c.TLSConfig.TLSServerName != "" {
		clientTLSConfig.ServerName = c.TLSConfig.TLSServerName
	}
	return nil
}
func ( c * Config ) ConfigureTLS ( ) error { if c . HTTPClient == nil { return fmt . Errorf ( " " ) } var clientCert tls . Certificate foundClientCert := false if c . TLSConfig . ClientCert != " " || c . TLSConfig . ClientKey != " " { if c . TLSConfig . ClientCert != " " && c . TLSConfig . ClientKey != " " { var err error clientCert , err = tls . LoadX509KeyPair ( c . TLSConfig . ClientCert , c . TLSConfig . ClientKey ) if err != nil { return err } foundClientCert = true } else { return fmt . Errorf ( " " ) } } clientTLSConfig := c . HTTPClient . Transport . ( * http . Transport ) . TLSClientConfig rootConfig := & rootcerts . Config { CAFile : c . TLSConfig . CACert , CAPath : c . TLSConfig . CAPath , } if err := rootcerts . ConfigureTLS ( clientTLSConfig , rootConfig ) ; err != nil { return err } clientTLSConfig . InsecureSkipVerify = c . TLSConfig . Insecure if foundClientCert { clientTLSConfig . Certificates = [ ] tls . Certificate { clientCert } } if c . TLSConfig . TLSServerName != " " { clientTLSConfig . ServerName = c . TLSConfig . TLSServerName } return nil }
ConfigureTLS applies a set of TLS configurations to the the HTTP client.
ConfigureTLS applies a set of TLS configurations to the the HTTP client .