Skip to content

Commit

Permalink
Removed 'Enabled' from backend tls configuration yyyar#40
Browse files Browse the repository at this point in the history
  • Loading branch information
illarion committed Mar 6, 2017
1 parent c2e887f commit 2126f1f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 16 deletions.
9 changes: 4 additions & 5 deletions config/gobetween.toml
Original file line number Diff line number Diff line change
Expand Up @@ -97,23 +97,22 @@ protocol = "udp"
#backend_idle_timeout = "10m"
#backend_connection_timeout = "5s"
#

# [servers.default.backends_tls] # (optional) backends tls options
# enabled = false # (required) if true, use tls in order to connect to backends
## ---------------- backends tls properties ----------------- #
#
# [servers.default.backends_tls] # (optional) backends tls options (if present -- conntect to backends via tls)
# ignore_verify = false # (optional) insecure, disable tls certificate verification while connecting to backends
# root_ca_cert_path = "/path/to/file.pem" # (optional) path to series of root PEM encoded certificates.
# By default the host's root CA set is used (on many linux distros it's /etc/ssl/cert.pem)
# # Client certificate used by gobetween to make authenticated requests to backends.
# # Use this only if required by backends
# cert_path = "/path/to/file.crt" # (optional) path to crt file
# key_path = "/path/to/file.key" # (optional) path to key file
#
# min_version = "tls1" # (optional) "ssl3" | "tls1" | "tls1.1" | "tls1.2" - minimum allowed tls version
# max_version = "tls1.2" # (optional) maximum allowed tls version
# ciphers = [] # (optional) list of supported ciphers. Empty means all supported. For a list see https://golang.org/pkg/crypto/tls/#pkg-constants
# prefer_server_ciphers = false # (optional) if true server selects server's most preferred cipher
# session_tickets = true # (optional) if true enables session tickets

#
#
#
## ---------------------- tls properties --------------------- #
Expand Down
1 change: 0 additions & 1 deletion src/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ type Tls struct {
}

type BackendsTls struct {
Enabled bool `toml:"enabled" json:"enabled"`
IgnoreVerify bool `toml:"ignore_verify" json:"ignore_verify"`
RootCaCertPath *string `toml:"root_ca_cert_path" json:"root_ca_cert_path"`
CertPath *string `toml:"cert_path" json:"cert_path"`
Expand Down
10 changes: 2 additions & 8 deletions src/manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,7 @@ func prepareConfig(name string, server config.Server, defaults config.Connection
return config.Server{}, errors.New("interval parsing error")
}

if server.BackendsTls == nil {
server.BackendsTls = &config.BackendsTls{
Enabled: false,
}
}

if server.BackendsTls.Enabled && ((server.BackendsTls.KeyPath == nil) != (server.BackendsTls.CertPath == nil)) {
if server.BackendsTls != nil && ((server.BackendsTls.KeyPath == nil) != (server.BackendsTls.CertPath == nil)) {
return config.Server{}, errors.New("backend_tls.cert_path and .key_path should be specified together")
}

Expand All @@ -248,7 +242,7 @@ func prepareConfig(name string, server config.Server, defaults config.Connection
fallthrough
case "tcp":
case "udp":
if server.BackendsTls.Enabled {
if server.BackendsTls != nil {
return config.Server{}, errors.New("backends_tls should not be enabled for udp protocol")
}
default:
Expand Down
4 changes: 2 additions & 2 deletions src/server/tcp/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func New(name string, cfg config.Server) (*Server, error) {
}

/* Add backend tls config if needed */
if cfg.BackendsTls.Enabled {
if cfg.BackendsTls != nil {
server.backendsTlsConfg, err = prepareBackendsTlsConfig(cfg)
if err != nil {
return nil, err
Expand Down Expand Up @@ -288,7 +288,7 @@ func (this *Server) handle(clientConn net.Conn) {
/* Connect to backend */
var backendConn net.Conn

if this.cfg.BackendsTls.Enabled {
if this.cfg.BackendsTls != nil {
backendConn, err = tls.DialWithDialer(&net.Dialer{
Timeout: utils.ParseDurationOrDefault(*this.cfg.BackendConnectionTimeout, 0),
}, "tcp", backend.Address(), this.backendsTlsConfg)
Expand Down

0 comments on commit 2126f1f

Please sign in to comment.