protonmail: skip keys we can't read

Updates https://github.com/emersion/hydroxide/issues/46
This commit is contained in:
Simon Ser 2019-04-14 21:10:01 +03:00
parent fc1618d086
commit ba96d886d8
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
1 changed files with 6 additions and 1 deletions

View File

@ -280,7 +280,8 @@ func (c *Client) Unlock(auth *Auth, passphrase string) (openpgp.EntityList, erro
for _, key := range addr.Keys { for _, key := range addr.Keys {
entity, err := key.Entity() entity, err := key.Entity()
if err != nil { 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 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 return keyRing, nil
} }