Skip to content

Commit

Permalink
Updates based on feedback
Browse files Browse the repository at this point in the history
Signed-off-by: Derek Collison <[email protected]>
  • Loading branch information
derekcollison committed Oct 29, 2018
1 parent e76c7a5 commit 4515025
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions nats.go
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ func Nkey(pubKey string, sigCB SignatureHandler) Option {
return func(o *Options) error {
o.Nkey = pubKey
o.SignatureCB = sigCB
if sigCB == nil {
if pubKey != "" && sigCB == nil {
return ErrNkeyButNoSigCB
}
return nil
Expand Down Expand Up @@ -823,6 +823,11 @@ func (o Options) Connect() (*Conn, error) {
nc.Opts.Timeout = DefaultTimeout
}

// Check if we have an nkey but no signature callback defined.
if nc.Opts.Nkey != "" && nc.Opts.SignatureCB == nil {
return nil, ErrNkeyButNoSigCB
}

// Allow custom Dialer for connecting using DialTimeout by default
if nc.Opts.Dialer == nil {
nc.Opts.Dialer = &net.Dialer{
Expand Down Expand Up @@ -1273,11 +1278,6 @@ func (nc *Conn) processExpectedInfo() error {
return ErrNkeysNoSupported
}

// Check if we have an nkey but no signature callback defined.
if nc.Opts.Nkey != "" && nc.Opts.SignatureCB == nil {
return ErrNkeyButNoSigCB
}

return nc.checkForSecure()
}

Expand Down

0 comments on commit 4515025

Please sign in to comment.