aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNIIBE Yutaka <[email protected]>2022-08-26 00:24:00 +0000
committerWerner Koch <[email protected]>2022-08-31 11:47:51 +0000
commit14ccabe7f82f64bbf84b8a880cd8b4a34cea9061 (patch)
tree730fa700a39c084fc4ed742ba497f4a35ffebe22
parentgpg: Fix assertion failure due to errors in encrypt_filter. (diff)
downloadgnupg-14ccabe7f82f64bbf84b8a880cd8b4a34cea9061.tar.gz
gnupg-14ccabe7f82f64bbf84b8a880cd8b4a34cea9061.zip
dirmngr: Reject certificate which is not valid into cache.
* dirmngr/certcache.c (put_cert): When PERMANENT, reject the certificate which is obviously invalid. -- With this change, invalid certificates from system won't be registered into cache. Then, an intermediate certificate which is issued by an entity certified by such an invalid certificate will be also rejected with GPG_ERR_INV_CERT_OBJ. With less invalid certificates in cache, it helps the validate_cert_chain function work better. GnuPG-bug-id: 6142 Signed-off-by: NIIBE Yutaka <[email protected]>
-rw-r--r--dirmngr/certcache.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/dirmngr/certcache.c b/dirmngr/certcache.c
index 8c85e6f1f..69c27aa9c 100644
--- a/dirmngr/certcache.c
+++ b/dirmngr/certcache.c
@@ -271,6 +271,20 @@ put_cert (ksba_cert_t cert, int permanent, unsigned int trustclass,
cert_item_t ci;
fingerprint_list_t ignored;
+ if (permanent)
+ { /* Do a little validation. */
+ ksba_isotime_t not_after;
+ ksba_isotime_t current_time;
+
+ if (ksba_cert_get_validity (cert, 1, not_after))
+ return gpg_error (GPG_ERR_BAD_CERT);
+
+ gnupg_get_isotime (current_time);
+
+ if (*not_after && strcmp (current_time, not_after) > 0)
+ return gpg_error (GPG_ERR_CERT_EXPIRED);
+ }
+
fpr = fpr_buffer? fpr_buffer : &help_fpr_buffer;
/* If we already reached the caching limit, drop a couple of certs