Browse Source

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
pull/1671/head
Alexander Simmerl 7 years ago
parent
commit
3255c076e5
No known key found for this signature in database GPG Key ID: 4694E95C9CC61BDA
14 changed files with 21 additions and 79 deletions
  1. +3
    -0
      CHANGELOG.md
  2. +0
    -4
      config/config.go
  3. +0
    -3
      config/toml.go
  4. +0
    -3
      docs/examples/node0/config/config.toml
  5. +0
    -3
      docs/examples/node1/config/config.toml
  6. +0
    -3
      docs/examples/node2/config/config.toml
  7. +0
    -3
      docs/examples/node3/config/config.toml
  8. +0
    -3
      docs/spec/p2p/peer.md
  9. +0
    -3
      docs/specification/configuration.rst
  10. +1
    -3
      docs/specification/secure-p2p.rst
  11. +0
    -3
      node/node.go
  12. +9
    -14
      p2p/peer.go
  13. +0
    -22
      p2p/peer_test.go
  14. +8
    -12
      p2p/switch.go

+ 3
- 0
CHANGELOG.md View File

@ -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:


+ 0
- 4
config/config.go View File

@ -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
} }
} }


+ 0
- 3
config/toml.go View File

@ -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 }}"


+ 0
- 3
docs/examples/node0/config/config.toml View File

@ -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 = ""


+ 0
- 3
docs/examples/node1/config/config.toml View File

@ -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 = ""


+ 0
- 3
docs/examples/node2/config/config.toml View File

@ -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 = ""


+ 0
- 3
docs/examples/node3/config/config.toml View File

@ -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 = ""


+ 0
- 3
docs/spec/p2p/peer.md View File

@ -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.


+ 0
- 3
docs/specification/configuration.rst View File

@ -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 = ""


+ 1
- 3
docs/specification/secure-p2p.rst View File

@ -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
authentication scheme or your peers are connected via VPN, you can turn it off
by setting ``auth_enc`` to ``false`` in the config file.
Authenticated encryption is enabled by default.
Additional Reading Additional Reading
------------------ ------------------


+ 0
- 3
node/node.go View File

@ -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)


+ 9
- 14
p2p/peer.go View File

@ -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,17 +184,15 @@ 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
if err := conn.SetDeadline(time.Now().Add(config.HandshakeTimeout * time.Second)); err != nil {
return pc, cmn.ErrorWrap(err, "Error setting deadline while encrypting connection")
}
// Set deadline for secret handshake
if err := conn.SetDeadline(time.Now().Add(config.HandshakeTimeout * time.Second)); err != nil {
return pc, cmn.ErrorWrap(err, "Error setting deadline while encrypting connection")
}
// Encrypt connection
conn, err = tmconn.MakeSecretConnection(conn, ourNodePrivKey)
if err != nil {
return pc, cmn.ErrorWrap(err, "Error creating peer")
}
// Encrypt connection
conn, err = tmconn.MakeSecretConnection(conn, ourNodePrivKey)
if err != nil {
return pc, cmn.ErrorWrap(err, "Error creating peer")
} }
// Only the information we already have // Only the information we already have


+ 0
- 22
p2p/peer_test.go View File

@ -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}


+ 8
- 12
p2p/switch.go View File

@ -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()
if peerID != connID {
return fmt.Errorf("nodeInfo.ID() (%v) doesn't match conn.ID() (%v)",
peerID, connID)
}
connID := pc.ID()
if peerID != connID {
return fmt.Errorf(
"nodeInfo.ID() (%v) doesn't match conn.ID() (%v)",
peerID,
connID,
)
} }
// Validate the peers nodeInfo // Validate the peers nodeInfo


Loading…
Cancel
Save