Merge pull request #180 from libp2p/feat/strict-signing

Strict message signing by default
This commit is contained in:
Steven Allen 2019-05-02 10:31:56 -07:00 committed by GitHub
commit 9db3dbdde9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 5 deletions

View File

@ -164,6 +164,7 @@ func NewPubSub(ctx context.Context, h host.Host, rt PubSubRouter, opts ...Option
rt: rt, rt: rt,
signID: h.ID(), signID: h.ID(),
signKey: h.Peerstore().PrivKey(h.ID()), signKey: h.Peerstore().PrivKey(h.ID()),
signStrict: true,
incoming: make(chan *RPC, 32), incoming: make(chan *RPC, 32),
publish: make(chan *Message), publish: make(chan *Message),
newPeers: make(chan peer.ID), newPeers: make(chan peer.ID),
@ -231,6 +232,7 @@ func WithMessageSigning(enabled bool) Option {
} }
} else { } else {
p.signKey = nil p.signKey = nil
p.signStrict = false
} }
return nil return nil
} }
@ -256,11 +258,8 @@ func WithMessageAuthor(author peer.ID) Option {
} }
} }
// WithStrictSignatureVerification enforces message signing. If set, unsigned // WithStrictSignatureVerification is an option to enable or disable strict message signing.
// messages will be discarded. // When enabled (which is the default), unsigned messages will be discarded.
//
// This currently defaults to false but, as we transition to signing by default,
// will eventually default to true.
func WithStrictSignatureVerification(required bool) Option { func WithStrictSignatureVerification(required bool) Option {
return func(p *PubSub) error { return func(p *PubSub) error {
p.signStrict = required p.signStrict = required