aboutsummaryrefslogtreecommitdiffstats
path: root/sm/certlist.c
diff options
context:
space:
mode:
Diffstat (limited to 'sm/certlist.c')
-rw-r--r--sm/certlist.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/sm/certlist.c b/sm/certlist.c
index 097f42d14..0035d527c 100644
--- a/sm/certlist.c
+++ b/sm/certlist.c
@@ -86,3 +86,31 @@ gpgsm_release_certlist (CERTLIST list)
}
}
+
+/* Like gpgsm_add_to_certlist, but lookonly for one certificate */
+int
+gpgsm_find_cert (const char *name, KsbaCert *r_cert)
+{
+ int rc;
+ KEYDB_SEARCH_DESC desc;
+ KEYDB_HANDLE kh = NULL;
+
+ *r_cert = NULL;
+ /* fixme: check that we identify excactly one cert with the name */
+ rc = keydb_classify_name (name, &desc);
+ if (!rc)
+ {
+ kh = keydb_new (0);
+ if (!kh)
+ rc = GNUPG_Out_Of_Core;
+ else
+ {
+ rc = keydb_search (kh, &desc, 1);
+ if (!rc)
+ rc = keydb_get_cert (kh, r_cert);
+ }
+ }
+
+ keydb_release (kh);
+ return rc == -1? GNUPG_No_Public_Key: rc;
+}