mirror of
https://github.com/fluencelabs/tendermint
synced 2025-04-29 16:52:15 +00:00
Remove auth_enc config option
As we didn't hear any voices requesting this feature, we removed the option to disable it and always have peer connection auth encrypted. closes #1518 follow-up #1325
This commit is contained in:
parent
178e357d7f
commit
3255c076e5
@ -1,5 +1,8 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
- [p2p] remove `auth_enc` config option, peer connections are always auth
|
||||||
|
encrypted
|
||||||
|
|
||||||
## 0.19.7
|
## 0.19.7
|
||||||
|
|
||||||
BREAKING:
|
BREAKING:
|
||||||
|
@ -287,9 +287,6 @@ type P2PConfig struct {
|
|||||||
// Does not work if the peer-exchange reactor is disabled.
|
// Does not work if the peer-exchange reactor is disabled.
|
||||||
SeedMode bool `mapstructure:"seed_mode"`
|
SeedMode bool `mapstructure:"seed_mode"`
|
||||||
|
|
||||||
// Authenticated encryption
|
|
||||||
AuthEnc bool `mapstructure:"auth_enc"`
|
|
||||||
|
|
||||||
// Comma separated list of peer IDs to keep private (will not be gossiped to other peers)
|
// Comma separated list of peer IDs to keep private (will not be gossiped to other peers)
|
||||||
PrivatePeerIDs string `mapstructure:"private_peer_ids"`
|
PrivatePeerIDs string `mapstructure:"private_peer_ids"`
|
||||||
|
|
||||||
@ -310,7 +307,6 @@ func DefaultP2PConfig() *P2PConfig {
|
|||||||
RecvRate: 512000, // 500 kB/s
|
RecvRate: 512000, // 500 kB/s
|
||||||
PexReactor: true,
|
PexReactor: true,
|
||||||
SeedMode: false,
|
SeedMode: false,
|
||||||
AuthEnc: true,
|
|
||||||
AllowDuplicateIP: true, // so non-breaking yet
|
AllowDuplicateIP: true, // so non-breaking yet
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -165,9 +165,6 @@ pex = {{ .P2P.PexReactor }}
|
|||||||
# Does not work if the peer-exchange reactor is disabled.
|
# Does not work if the peer-exchange reactor is disabled.
|
||||||
seed_mode = {{ .P2P.SeedMode }}
|
seed_mode = {{ .P2P.SeedMode }}
|
||||||
|
|
||||||
# Authenticated encryption
|
|
||||||
auth_enc = {{ .P2P.AuthEnc }}
|
|
||||||
|
|
||||||
# Comma separated list of peer IDs to keep private (will not be gossiped to other peers)
|
# Comma separated list of peer IDs to keep private (will not be gossiped to other peers)
|
||||||
private_peer_ids = "{{ .P2P.PrivatePeerIDs }}"
|
private_peer_ids = "{{ .P2P.PrivatePeerIDs }}"
|
||||||
|
|
||||||
|
@ -103,9 +103,6 @@ pex = true
|
|||||||
# Does not work if the peer-exchange reactor is disabled.
|
# Does not work if the peer-exchange reactor is disabled.
|
||||||
seed_mode = false
|
seed_mode = false
|
||||||
|
|
||||||
# Authenticated encryption
|
|
||||||
auth_enc = true
|
|
||||||
|
|
||||||
# Comma separated list of peer IDs to keep private (will not be gossiped to other peers)
|
# Comma separated list of peer IDs to keep private (will not be gossiped to other peers)
|
||||||
private_peer_ids = ""
|
private_peer_ids = ""
|
||||||
|
|
||||||
|
@ -103,9 +103,6 @@ pex = true
|
|||||||
# Does not work if the peer-exchange reactor is disabled.
|
# Does not work if the peer-exchange reactor is disabled.
|
||||||
seed_mode = false
|
seed_mode = false
|
||||||
|
|
||||||
# Authenticated encryption
|
|
||||||
auth_enc = true
|
|
||||||
|
|
||||||
# Comma separated list of peer IDs to keep private (will not be gossiped to other peers)
|
# Comma separated list of peer IDs to keep private (will not be gossiped to other peers)
|
||||||
private_peer_ids = ""
|
private_peer_ids = ""
|
||||||
|
|
||||||
|
@ -103,9 +103,6 @@ pex = true
|
|||||||
# Does not work if the peer-exchange reactor is disabled.
|
# Does not work if the peer-exchange reactor is disabled.
|
||||||
seed_mode = false
|
seed_mode = false
|
||||||
|
|
||||||
# Authenticated encryption
|
|
||||||
auth_enc = true
|
|
||||||
|
|
||||||
# Comma separated list of peer IDs to keep private (will not be gossiped to other peers)
|
# Comma separated list of peer IDs to keep private (will not be gossiped to other peers)
|
||||||
private_peer_ids = ""
|
private_peer_ids = ""
|
||||||
|
|
||||||
|
@ -103,9 +103,6 @@ pex = true
|
|||||||
# Does not work if the peer-exchange reactor is disabled.
|
# Does not work if the peer-exchange reactor is disabled.
|
||||||
seed_mode = false
|
seed_mode = false
|
||||||
|
|
||||||
# Authenticated encryption
|
|
||||||
auth_enc = true
|
|
||||||
|
|
||||||
# Comma separated list of peer IDs to keep private (will not be gossiped to other peers)
|
# Comma separated list of peer IDs to keep private (will not be gossiped to other peers)
|
||||||
private_peer_ids = ""
|
private_peer_ids = ""
|
||||||
|
|
||||||
|
@ -17,9 +17,6 @@ We will attempt to connect to the peer at IP:PORT, and verify,
|
|||||||
via authenticated encryption, that it is in possession of the private key
|
via authenticated encryption, that it is in possession of the private key
|
||||||
corresponding to `<ID>`. This prevents man-in-the-middle attacks on the peer layer.
|
corresponding to `<ID>`. This prevents man-in-the-middle attacks on the peer layer.
|
||||||
|
|
||||||
If `auth_enc = false`, peers can use an arbitrary ID, but they must always use
|
|
||||||
one. Authentication can then happen out-of-band of Tendermint, for instance via VPN.
|
|
||||||
|
|
||||||
## Connections
|
## Connections
|
||||||
|
|
||||||
All p2p connections use TCP.
|
All p2p connections use TCP.
|
||||||
|
@ -122,9 +122,6 @@ like the file below, however, double check by inspecting the
|
|||||||
# Does not work if the peer-exchange reactor is disabled.
|
# Does not work if the peer-exchange reactor is disabled.
|
||||||
seed_mode = false
|
seed_mode = false
|
||||||
|
|
||||||
# Authenticated encryption
|
|
||||||
auth_enc = true
|
|
||||||
|
|
||||||
# Comma separated list of peer IDs to keep private (will not be gossiped to other peers)
|
# Comma separated list of peer IDs to keep private (will not be gossiped to other peers)
|
||||||
private_peer_ids = ""
|
private_peer_ids = ""
|
||||||
|
|
||||||
|
@ -65,9 +65,7 @@ are connected to at least one validator.
|
|||||||
Config
|
Config
|
||||||
------
|
------
|
||||||
|
|
||||||
Authenticated encryption is enabled by default. If you wish to use another
|
Authenticated encryption is enabled by default.
|
||||||
authentication scheme or your peers are connected via VPN, you can turn it off
|
|
||||||
by setting ``auth_enc`` to ``false`` in the config file.
|
|
||||||
|
|
||||||
Additional Reading
|
Additional Reading
|
||||||
------------------
|
------------------
|
||||||
|
@ -269,9 +269,6 @@ func NewNode(config *cfg.Config,
|
|||||||
// but it would still be nice to have a clear list of the current "PersistentPeers"
|
// but it would still be nice to have a clear list of the current "PersistentPeers"
|
||||||
// somewhere that we can return with net_info.
|
// somewhere that we can return with net_info.
|
||||||
//
|
//
|
||||||
// Let's assume we always have IDs ... and we just dont authenticate them
|
|
||||||
// if auth_enc=false.
|
|
||||||
//
|
|
||||||
// If PEX is on, it should handle dialing the seeds. Otherwise the switch does it.
|
// If PEX is on, it should handle dialing the seeds. Otherwise the switch does it.
|
||||||
// Note we currently use the addrBook regardless at least for AddOurAddress
|
// Note we currently use the addrBook regardless at least for AddOurAddress
|
||||||
addrBook := pex.NewAddrBook(config.P2P.AddrBookFile(), config.P2P.AddrBookStrict)
|
addrBook := pex.NewAddrBook(config.P2P.AddrBookFile(), config.P2P.AddrBookStrict)
|
||||||
|
@ -116,8 +116,6 @@ func newPeer(pc peerConn, nodeInfo NodeInfo,
|
|||||||
|
|
||||||
// PeerConfig is a Peer configuration.
|
// PeerConfig is a Peer configuration.
|
||||||
type PeerConfig struct {
|
type PeerConfig struct {
|
||||||
AuthEnc bool `mapstructure:"auth_enc"` // authenticated encryption
|
|
||||||
|
|
||||||
// times are in seconds
|
// times are in seconds
|
||||||
HandshakeTimeout time.Duration `mapstructure:"handshake_timeout"`
|
HandshakeTimeout time.Duration `mapstructure:"handshake_timeout"`
|
||||||
DialTimeout time.Duration `mapstructure:"dial_timeout"`
|
DialTimeout time.Duration `mapstructure:"dial_timeout"`
|
||||||
@ -132,7 +130,6 @@ type PeerConfig struct {
|
|||||||
// DefaultPeerConfig returns the default config.
|
// DefaultPeerConfig returns the default config.
|
||||||
func DefaultPeerConfig() *PeerConfig {
|
func DefaultPeerConfig() *PeerConfig {
|
||||||
return &PeerConfig{
|
return &PeerConfig{
|
||||||
AuthEnc: true,
|
|
||||||
HandshakeTimeout: 20, // * time.Second,
|
HandshakeTimeout: 20, // * time.Second,
|
||||||
DialTimeout: 3, // * time.Second,
|
DialTimeout: 3, // * time.Second,
|
||||||
MConfig: tmconn.DefaultMConnConfig(),
|
MConfig: tmconn.DefaultMConnConfig(),
|
||||||
@ -159,7 +156,7 @@ func newOutboundPeerConn(addr *NetAddress, config *PeerConfig, persistent bool,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ensure dialed ID matches connection ID
|
// ensure dialed ID matches connection ID
|
||||||
if config.AuthEnc && addr.ID != pc.ID() {
|
if addr.ID != pc.ID() {
|
||||||
if err2 := conn.Close(); err2 != nil {
|
if err2 := conn.Close(); err2 != nil {
|
||||||
return pc, cmn.ErrorWrap(err, err2.Error())
|
return pc, cmn.ErrorWrap(err, err2.Error())
|
||||||
}
|
}
|
||||||
@ -187,7 +184,6 @@ func newPeerConn(rawConn net.Conn,
|
|||||||
conn = FuzzConnAfterFromConfig(conn, 10*time.Second, config.FuzzConfig)
|
conn = FuzzConnAfterFromConfig(conn, 10*time.Second, config.FuzzConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.AuthEnc {
|
|
||||||
// Set deadline for secret handshake
|
// Set deadline for secret handshake
|
||||||
if err := conn.SetDeadline(time.Now().Add(config.HandshakeTimeout * time.Second)); err != nil {
|
if err := conn.SetDeadline(time.Now().Add(config.HandshakeTimeout * time.Second)); err != nil {
|
||||||
return pc, cmn.ErrorWrap(err, "Error setting deadline while encrypting connection")
|
return pc, cmn.ErrorWrap(err, "Error setting deadline while encrypting connection")
|
||||||
@ -198,7 +194,6 @@ func newPeerConn(rawConn net.Conn,
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return pc, cmn.ErrorWrap(err, "Error creating peer")
|
return pc, cmn.ErrorWrap(err, "Error creating peer")
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Only the information we already have
|
// Only the information we already have
|
||||||
return peerConn{
|
return peerConn{
|
||||||
|
@ -41,32 +41,10 @@ func TestPeerBasic(t *testing.T) {
|
|||||||
assert.Equal(rp.ID(), p.ID())
|
assert.Equal(rp.ID(), p.ID())
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPeerWithoutAuthEnc(t *testing.T) {
|
|
||||||
assert, require := assert.New(t), require.New(t)
|
|
||||||
|
|
||||||
config := DefaultPeerConfig()
|
|
||||||
config.AuthEnc = false
|
|
||||||
|
|
||||||
// simulate remote peer
|
|
||||||
rp := &remotePeer{PrivKey: crypto.GenPrivKeyEd25519(), Config: config}
|
|
||||||
rp.Start()
|
|
||||||
defer rp.Stop()
|
|
||||||
|
|
||||||
p, err := createOutboundPeerAndPerformHandshake(rp.Addr(), config)
|
|
||||||
require.Nil(err)
|
|
||||||
|
|
||||||
err = p.Start()
|
|
||||||
require.Nil(err)
|
|
||||||
defer p.Stop()
|
|
||||||
|
|
||||||
assert.True(p.IsRunning())
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestPeerSend(t *testing.T) {
|
func TestPeerSend(t *testing.T) {
|
||||||
assert, require := assert.New(t), require.New(t)
|
assert, require := assert.New(t), require.New(t)
|
||||||
|
|
||||||
config := DefaultPeerConfig()
|
config := DefaultPeerConfig()
|
||||||
config.AuthEnc = false
|
|
||||||
|
|
||||||
// simulate remote peer
|
// simulate remote peer
|
||||||
rp := &remotePeer{PrivKey: crypto.GenPrivKeyEd25519(), Config: config}
|
rp := &remotePeer{PrivKey: crypto.GenPrivKeyEd25519(), Config: config}
|
||||||
|
@ -95,7 +95,6 @@ func NewSwitch(config *cfg.P2PConfig) *Switch {
|
|||||||
sw.peerConfig.MConfig.SendRate = config.SendRate
|
sw.peerConfig.MConfig.SendRate = config.SendRate
|
||||||
sw.peerConfig.MConfig.RecvRate = config.RecvRate
|
sw.peerConfig.MConfig.RecvRate = config.RecvRate
|
||||||
sw.peerConfig.MConfig.MaxPacketMsgPayloadSize = config.MaxPacketMsgPayloadSize
|
sw.peerConfig.MConfig.MaxPacketMsgPayloadSize = config.MaxPacketMsgPayloadSize
|
||||||
sw.peerConfig.AuthEnc = config.AuthEnc
|
|
||||||
|
|
||||||
sw.BaseService = *cmn.NewBaseService(nil, "P2P Switch", sw)
|
sw.BaseService = *cmn.NewBaseService(nil, "P2P Switch", sw)
|
||||||
return sw
|
return sw
|
||||||
@ -534,10 +533,6 @@ func (sw *Switch) addPeer(pc peerConn) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: if AuthEnc==false, we don't have a peerID until after the handshake.
|
|
||||||
// If AuthEnc==true then we already know the ID and could do the checks first before the handshake,
|
|
||||||
// but it's simple to just deal with both cases the same after the handshake.
|
|
||||||
|
|
||||||
// Exchange NodeInfo on the conn
|
// Exchange NodeInfo on the conn
|
||||||
peerNodeInfo, err := pc.HandshakeTimeout(sw.nodeInfo, time.Duration(sw.peerConfig.HandshakeTimeout*time.Second))
|
peerNodeInfo, err := pc.HandshakeTimeout(sw.nodeInfo, time.Duration(sw.peerConfig.HandshakeTimeout*time.Second))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -547,13 +542,14 @@ func (sw *Switch) addPeer(pc peerConn) error {
|
|||||||
peerID := peerNodeInfo.ID
|
peerID := peerNodeInfo.ID
|
||||||
|
|
||||||
// ensure connection key matches self reported key
|
// ensure connection key matches self reported key
|
||||||
if pc.config.AuthEnc {
|
|
||||||
connID := pc.ID()
|
connID := pc.ID()
|
||||||
|
|
||||||
if peerID != connID {
|
if peerID != connID {
|
||||||
return fmt.Errorf("nodeInfo.ID() (%v) doesn't match conn.ID() (%v)",
|
return fmt.Errorf(
|
||||||
peerID, connID)
|
"nodeInfo.ID() (%v) doesn't match conn.ID() (%v)",
|
||||||
}
|
peerID,
|
||||||
|
connID,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate the peers nodeInfo
|
// Validate the peers nodeInfo
|
||||||
|
Loading…
x
Reference in New Issue
Block a user