Skip to content

Commit c29fff7

Browse files
committed
openpgp: fix handling expired keys
exclude expired keys from the GoodKeys
1 parent c0c4bc3 commit c29fff7

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

pgp/internal.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,10 +455,11 @@ func (g *GoVerifier) VerifyClearsigned(clearsigned io.Reader, showKeyTip bool) (
455455

456456
for _, signer := range signers {
457457
if signer.Entity != nil {
458-
result.GoodKeys = append(result.GoodKeys, KeyFromUint64(signer.IssuerKeyID))
458+
if !signer.IsExpired {
459+
result.GoodKeys = append(result.GoodKeys, KeyFromUint64(signer.IssuerKeyID))
460+
}
459461
} else {
460462
result.MissingKeys = append(result.MissingKeys, KeyFromUint64(signer.IssuerKeyID))
461-
462463
}
463464
}
464465

pgp/openpgp.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ func hashForSignature(hashID crypto.Hash, sigType packet.SignatureType) (hash.Ha
4040

4141
type signatureResult struct {
4242
CreationTime time.Time
43+
IsExpired bool
4344
IssuerKeyID uint64
4445
PubKeyAlgo packet.PublicKeyAlgorithm
4546
Entity *openpgp.Entity
@@ -59,6 +60,8 @@ func checkDetachedSignature(keyring openpgp.KeyRing, signed, signature io.Reader
5960
return nil, 0, e
6061
}
6162

63+
var now = time.Now()
64+
6265
packets := packet.NewReader(signature)
6366
for {
6467
p, err = packets.Next()
@@ -87,6 +90,9 @@ func checkDetachedSignature(keyring openpgp.KeyRing, signed, signature io.Reader
8790
if sig.IssuerKeyId == nil {
8891
return nil, 0, errors.StructuralError("signature doesn't have an issuer")
8992
}
93+
if sig.SigExpired(now) {
94+
continue
95+
}
9096
issuerKeyID = *sig.IssuerKeyId
9197
hashFunc = sig.Hash
9298
sigType = sig.SigType
@@ -128,6 +134,7 @@ func checkDetachedSignature(keyring openpgp.KeyRing, signed, signature io.Reader
128134
if err == nil {
129135
signers = append(signers, signatureResult{
130136
CreationTime: creationTime,
137+
IsExpired: key.PublicKey.KeyExpired(key.SelfSignature, now),
131138
IssuerKeyID: issuerKeyID,
132139
PubKeyAlgo: pubKeyAlgo,
133140
Entity: key.Entity,

0 commit comments

Comments
 (0)