浏览代码

2008-09-29 Marcus Brinkmann <marcus@g10code.com>

	* src/gpgsm.c (struct search): New member WITH_CHAIN.
	(search_cb): Only load chain if WITH_CHAIN is true.
	(scute_gpgsm_get_cert): Call search_cb in the agent code path.
Marcus Brinkmann 17 年之前
父节点
当前提交
303c53ed4d
共有 2 个文件被更改,包括 14 次插入5 次删除
  1. 6 0
      ChangeLog
  2. 8 5
      src/gpgsm.c

+ 6 - 0
ChangeLog

@@ -1,3 +1,9 @@
+2008-09-29  Marcus Brinkmann  <marcus@g10code.com>
+
+	* src/gpgsm.c (struct search): New member WITH_CHAIN.
+	(search_cb): Only load chain if WITH_CHAIN is true.
+	(scute_gpgsm_get_cert): Call search_cb in the agent code path.
+
 2008-09-29  Marcus Brinkmann  <marcus@g10code.com>
 2008-09-29  Marcus Brinkmann  <marcus@g10code.com>
 
 
 	* src/slots.c (MIN): Remove macro.
 	* src/slots.c (MIN): Remove macro.

+ 8 - 5
src/gpgsm.c

@@ -46,6 +46,7 @@
 #include "cert.h"
 #include "cert.h"
 #include "agent.h"
 #include "agent.h"
 #include "gpgsm.h"
 #include "gpgsm.h"
+#include "debug.h"
 
 
 
 
 struct search
 struct search
@@ -53,7 +54,7 @@ struct search
   bool found;
   bool found;
   cert_get_cb_t cert_get_cb;
   cert_get_cb_t cert_get_cb;
   void *hook;
   void *hook;
-
+  bool with_chain;
 };
 };
 
 
 
 
@@ -87,7 +88,7 @@ search_cb (void *hook, struct cert *cert)
      certificate.  But ignore errors.  If the chain is incomplete, we
      certificate.  But ignore errors.  If the chain is incomplete, we
      might still be able to proceed, for example with client
      might still be able to proceed, for example with client
      authentication.  */
      authentication.  */
-  if (strcmp (cert->chain_id, cert->fpr))
+  if (ctx->with_chain && strcmp (cert->chain_id, cert->fpr))
     err = scute_gpgsm_search_certs_by_fpr (cert->chain_id, search_cb, ctx);
     err = scute_gpgsm_search_certs_by_fpr (cert->chain_id, search_cb, ctx);
 
 
   /* Turn this certificate into a certificate object.  */
   /* Turn this certificate into a certificate object.  */
@@ -119,6 +120,7 @@ scute_gpgsm_get_cert (char *grip, int no, cert_get_cb_t cert_get_cb, void *hook)
   search.found = false;
   search.found = false;
   search.cert_get_cb = cert_get_cb;
   search.cert_get_cb = cert_get_cb;
   search.hook = hook;
   search.hook = hook;
+  search.with_chain = false;
 
 
   /* If the key is from the card, we might get the certificate from
   /* If the key is from the card, we might get the certificate from
      the card as well.  */
      the card as well.  */
@@ -137,13 +139,14 @@ scute_gpgsm_get_cert (char *grip, int no, cert_get_cb_t cert_get_cb, void *hook)
 	     parse that and fill out the missing info and try to get the
 	     parse that and fill out the missing info and try to get the
 	     certificate chain from gpgsm.  */
 	     certificate chain from gpgsm.  */
 	  err = scute_cert_from_der (&cert);
 	  err = scute_cert_from_der (&cert);
-	  if (! err)
-	    err = search_cb (hook, &cert);
 #endif
 #endif
+	  if (! err)
+	    err = search_cb (&search, &cert);
 	  return err;
 	  return err;
 	}
 	}
     }
     }
-
+  
+  search.with_chain = true;
   err = scute_gpgsm_search_certs_by_grip (grip, search_cb, &search);
   err = scute_gpgsm_search_certs_by_grip (grip, search_cb, &search);
   return err;
   return err;
 }
 }