diff --git a/client/internal/login.go b/client/internal/login.go index 08efd514755..9b6cf7848d4 100644 --- a/client/internal/login.go +++ b/client/internal/login.go @@ -68,7 +68,7 @@ func Login(ctx context.Context, config *Config, setupKey string, jwtToken string } serverKey, err := doMgmLogin(ctx, mgmClient, pubSSHKey) - if isRegistrationNeeded(err) { + if serverKey != nil && isRegistrationNeeded(err) { log.Debugf("peer registration required") _, err = registerPeer(ctx, *serverKey, mgmClient, setupKey, jwtToken, pubSSHKey) return err diff --git a/management/client/grpc.go b/management/client/grpc.go index 0b1804906c2..c6d1d575338 100644 --- a/management/client/grpc.go +++ b/management/client/grpc.go @@ -276,7 +276,8 @@ func (c *GrpcClient) GetServerPublicKey() (*wgtypes.Key, error) { defer cancel() resp, err := c.realClient.GetServerKey(mgmCtx, &proto.Empty{}) if err != nil { - return nil, err + log.Errorf("failed while getting Management Service public key: %v", err) + return nil, fmt.Errorf("failed while getting Management Service public key") } serverKey, err := wgtypes.ParseKey(resp.Key)