auto-key-locate

David Shaw dshaw at jabberwocky.com
Mon May 22 18:20:58 CEST 2006


On Thu, May 18, 2006 at 02:32:24PM +0200, Simon Josefsson wrote:
> Werner Koch <wk at gnupg.org> writes:
> 
> >     * New auto-key-locate option that takes an ordered list of methods
> >       to locate a key if it is not available at encryption time (-r or
> >       --recipient).  Possible methods include "cert" (use DNS CERT as
> >       per RFC2538bis, "pka" (use DNS PKA), "ldap" (consult the LDAP
> >       server for the domain in question), "keyserver" (use the
> >       currently defined keyserver), as well as arbitrary keyserver
> >       URIs that will be contacted for the key.
> 
> I'm having trouble getting hkp keyservers to work with
> auto-key-locate.  gpg do appear to retrieve the key successfully, but
> then it complains that it can't use it.  Ideas?

It's not HKP keyservers, exactly.  It's any keyserver that returns
more than one key, when the last key that is returned is not valid.
Here's a patch.

David
-------------- next part --------------
Index: getkey.c
===================================================================
--- getkey.c	(revision 4137)
+++ getkey.c	(working copy)
@@ -934,7 +934,7 @@
 
       for(akl=opt.auto_key_locate;akl;akl=akl->next)
 	{
-	  unsigned char *fpr;
+	  unsigned char *fpr=NULL;
 	  size_t fpr_len;
 
 	  switch(akl->type)
Index: import.c
===================================================================
--- import.c	(revision 4137)
+++ import.c	(working copy)
@@ -696,9 +696,6 @@
 
     pk = node->pkt->pkt.public_key;
 
-    if(fpr)
-      *fpr=fingerprint_from_pk(pk,NULL,fpr_len);
-
     keyid_from_pk( pk, keyid );
     uidnode = find_next_kbnode( keyblock, PKT_USER_ID );
 
@@ -981,6 +978,17 @@
       }
     else if(new_key)
       {
+	if(fpr && stats->imported==1)
+	  {
+	    xfree(*fpr);
+	    *fpr=fingerprint_from_pk(pk,NULL,fpr_len);
+	  }
+	else
+	  {
+	    xfree(*fpr);
+	    *fpr=NULL;
+	  }
+
 	revocation_present(keyblock);
 	if(seckey_available(keyid)==0)
 	  check_prefs(keyblock);



More information about the Gnupg-users mailing list