Skip to content

Commit

Permalink
Only useable keys if trustmodel is not alwaystrust (gopasspw#664)
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikschulz authored Feb 22, 2018
1 parent 9f63c2c commit 6ff2cd1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions backend/crypto/gpg/cli/keyring.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ func (g *GPG) ListPublicKeyIDs(ctx context.Context) ([]string, error) {
}
g.pubKeys = kl
}
if gpg.IsAlwaysTrust(ctx) {
return g.pubKeys.Recipients(), nil
}
return g.pubKeys.UseableKeys().Recipients(), nil
}

Expand All @@ -46,6 +49,9 @@ func (g *GPG) FindPublicKeys(ctx context.Context, search ...string) ([]string, e
if err != nil || kl == nil {
return nil, err
}
if gpg.IsAlwaysTrust(ctx) {
return kl.Recipients(), nil
}
return kl.UseableKeys().Recipients(), nil
}

Expand All @@ -58,6 +64,9 @@ func (g *GPG) ListPrivateKeyIDs(ctx context.Context) ([]string, error) {
}
g.privKeys = kl
}
if gpg.IsAlwaysTrust(ctx) {
return g.privKeys.Recipients(), nil
}
return g.privKeys.UseableKeys().Recipients(), nil
}

Expand All @@ -67,6 +76,9 @@ func (g *GPG) FindPrivateKeys(ctx context.Context, search ...string) ([]string,
if err != nil || kl == nil {
return nil, err
}
if gpg.IsAlwaysTrust(ctx) {
return kl.Recipients(), nil
}
return kl.UseableKeys().Recipients(), nil
}

Expand Down
2 changes: 2 additions & 0 deletions store/sub/gpg.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ func (s *Store) ImportMissingPublicKeys(ctx context.Context) error {
}
}

out.Debug(ctx, "[%s] Public Key %s not found in keyring, importing", s.alias, r)

// try to load this recipient
if err := s.importPublicKey(ctx, r); err != nil {
out.Red(ctx, "[%s] Failed to import public key for %s: %s", s.alias, r, err)
Expand Down

0 comments on commit 6ff2cd1

Please sign in to comment.