From ba96d886d8a8672c4a6fc975691cbccd2924882b Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Sun, 14 Apr 2019 21:10:01 +0300 Subject: [PATCH] protonmail: skip keys we can't read Updates https://github.com/emersion/hydroxide/issues/46 --- protonmail/auth.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/protonmail/auth.go b/protonmail/auth.go index e971844..8b75e2b 100644 --- a/protonmail/auth.go +++ b/protonmail/auth.go @@ -280,7 +280,8 @@ func (c *Client) Unlock(auth *Auth, passphrase string) (openpgp.EntityList, erro for _, key := range addr.Keys { entity, err := key.Entity() if err != nil { - return nil, fmt.Errorf("failed to read key %q: %v", addr.Email, err) + log.Printf("warning: failed to read key %q: %v", addr.Email, err) + continue } found := false @@ -303,6 +304,10 @@ func (c *Client) Unlock(auth *Auth, passphrase string) (openpgp.EntityList, erro } } + if len(keyRing) == 0 { + return nil, fmt.Errorf("failed to unlock any key") + } + return keyRing, nil }