protonmail: Do not duplicate primary account key in keyring.

Probably not worth the extra overhead the way I did it, but neater.
This commit is contained in:
Brandon McDonnell 2018-07-09 11:06:30 -04:00 committed by emersion
parent c610c633a8
commit 7b92deb6ac
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
1 changed files with 10 additions and 8 deletions

View File

@ -269,20 +269,22 @@ func (c *Client) Unlock(auth *Auth, passphrase string) (openpgp.EntityList, erro
var keyRing2 openpgp.EntityList var keyRing2 openpgp.EntityList
for _, e := range u.Addresses { for _, e := range u.Addresses {
for _, f := range e.Keys { for _, f := range e.Keys {
prKey, err := openpgp.ReadArmoredKeyRing(strings.NewReader(f.PrivateKey)) pkey, err := f.Entity()
//pkey, err := f.Entity()
if err != nil { if err != nil {
return nil, err return nil, err
} }
if pkey.PrimaryKey.KeyId == keyRing[0].PrimaryKey.KeyId {
continue
}
prKey, err := openpgp.ReadArmoredKeyRing(strings.NewReader(f.PrivateKey))
// TODO Are these errors fatal?
if err != nil {
continue
}
if len(prKey) == 0 { if len(prKey) == 0 {
return nil, errors.New("auth key ring is empty") continue
} }
keyRing2 = append(keyRing2, prKey[0]) keyRing2 = append(keyRing2, prKey[0])
//fmt.Println(e.Email, " key ", pkey.PrimaryKey.KeyId)
//if pkey.PrimaryKey.KeyId != keyRing[0].PrimaryKey.KeyId {
// keyRing = append(keyRing, pkey)
//}
} }
} }
for _, e := range keyRing2 { for _, e := range keyRing2 {