aboutsummaryrefslogtreecommitdiffstats
path: root/sm/keydb.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2002-01-15 13:02:47 +0000
committerWerner Koch <[email protected]>2002-01-15 13:02:47 +0000
commita9979e26a5705f73ef80ae453d2c1ba1362f0426 (patch)
treec5a6f1feb34cabb1610165ddc144edbf9f6b608e /sm/keydb.c
parent* keybox-search.c (blob_cmp_fpr): New. (diff)
downloadgnupg-a9979e26a5705f73ef80ae453d2c1ba1362f0426.tar.gz
gnupg-a9979e26a5705f73ef80ae453d2c1ba1362f0426.zip
* import.c (gpgsm_import): Just do a basic cert check before
storing it. * certpath.c (gpgsm_basic_cert_check): New. * keydb.c (keydb_store_cert): New. * import.c (store_cert): Removed and change all caller to use the new function. * verify.c (store_cert): Ditto. * certlist.c (gpgsm_add_to_certlist): Validate the path * certpath.c (gpgsm_validate_path): Check the trust list. * call-agent.c (gpgsm_agent_istrusted): New.
Diffstat (limited to '')
-rw-r--r--sm/keydb.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/sm/keydb.c b/sm/keydb.c
index 17074e800..34e7adc9d 100644
--- a/sm/keydb.c
+++ b/sm/keydb.c
@@ -1143,3 +1143,58 @@ keydb_classify_name (const char *name, KEYDB_SEARCH_DESC *desc)
return 0;
}
+
+/* Store the certificate in the key Db but make sure that it does not
+ already exists. We do this simply by comparing the fingerprint */
+int
+keydb_store_cert (KsbaCert cert)
+{
+ KEYDB_HANDLE kh;
+ int rc;
+ unsigned char fpr[20];
+
+ if (!gpgsm_get_fingerprint (cert, 0, fpr, NULL))
+ {
+ log_error (_("failed to get the fingerprint\n"));
+ return GNUPG_General_Error;
+ }
+
+ kh = keydb_new (0);
+ if (!kh)
+ {
+ log_error (_("failed to allocate keyDB handle\n"));
+ return GNUPG_Out_Of_Core;
+ }
+
+ rc = keydb_search_fpr (kh, fpr);
+ if (rc != -1)
+ {
+ keydb_release (kh);
+ if (!rc)
+ return 0; /* okay */
+ log_error (_("problem looking for existing certificate: %s\n"),
+ gnupg_strerror (rc));
+ return rc;
+ }
+
+ rc = keydb_locate_writable (kh, 0);
+ if (rc)
+ {
+ log_error (_("error finding writable keyDB: %s\n"), gnupg_strerror (rc));
+ keydb_release (kh);
+ return rc;
+ }
+
+ rc = keydb_insert_cert (kh, cert);
+ if (rc)
+ {
+ log_error (_("error storing certificate: %s\n"), gnupg_strerror (rc));
+ keydb_release (kh);
+ return rc;
+ }
+ keydb_release (kh);
+ return 0;
+}
+
+
+