mirror of https://github.com/status-im/consul.git
consul: Enforce TLS if VerifyIncoming is set
This commit is contained in:
parent
7884439b7c
commit
f94dfa4efc
|
@ -61,6 +61,25 @@ func (s *Server) handleConn(conn net.Conn) {
|
|||
return
|
||||
}
|
||||
|
||||
// Check if entering TLS mode
|
||||
isTLS := false
|
||||
if RPCType(buf[0]) == rpcTLS {
|
||||
if s.rpcTLS == nil {
|
||||
s.logger.Printf("[WARN] consul.rpc: TLS connection attempted, server not configured for TLS")
|
||||
conn.Close()
|
||||
return
|
||||
}
|
||||
conn = tls.Server(conn, s.rpcTLS)
|
||||
isTLS = true
|
||||
}
|
||||
|
||||
// Enforce TLS if VerifyIncoming is set
|
||||
if s.config.VerifyIncoming && !isTLS {
|
||||
s.logger.Printf("[WARN] consul.rpc: Non-TLS connection attempted with VerifyIncoming set")
|
||||
conn.Close()
|
||||
return
|
||||
}
|
||||
|
||||
// Switch on the byte
|
||||
switch RPCType(buf[0]) {
|
||||
case rpcConsul:
|
||||
|
@ -73,15 +92,6 @@ func (s *Server) handleConn(conn net.Conn) {
|
|||
case rpcMultiplex:
|
||||
s.handleMultiplex(conn)
|
||||
|
||||
case rpcTLS:
|
||||
if s.rpcTLS == nil {
|
||||
s.logger.Printf("[WARN] consul.rpc: TLS connection attempted, server not configured for TLS")
|
||||
conn.Close()
|
||||
return
|
||||
}
|
||||
conn = tls.Server(conn, s.rpcTLS)
|
||||
s.handleConn(conn)
|
||||
|
||||
default:
|
||||
s.logger.Printf("[ERR] consul.rpc: unrecognized RPC byte: %v", buf[0])
|
||||
conn.Close()
|
||||
|
|
Loading…
Reference in New Issue