importing keys from keyservers (with search functionality)

Soren Dayton dayton at
Tue Oct 12 23:25:52 CEST 1999

I'm moving some of my users over to gnupg from pgp5, and one of the
problems has been that there is no functionality equivalent to:

        pgpk -a hkp://

where `foo' is an arbitrary string, not just a keyID (as in gpg)

Looking at the gpg source (g10/hkp.c) I guessed that something like
this would work

connect to host at port 11371.  Do a

        GET /pks/lookup?op=get&search=%s

and this is what pgp5 does.

Is there some reason that gpg doesn't support something like this?  In 
any case, here is a half-assed python script to give this
functionality externally (the ease with which this is done is almost
an argument NOT to have this in gpg, except that you already have this 
by specifying the EXACT keyid)

Soren Dayton
dayton at

#! /usr/local/bin/python

from httplib import HTTP
import os
import getopt
import sys

server = ''
port = 11371

baseurl = "/pks/lookup?op=get&search="

options, searchfor = getopt.getopt(sys.argv[1:],'s:p:')

for pair in options:
    option, value = pair
    if option == '-s':
        server = value
    elif option == '-p':
        port = value

h = HTTP(server, port)
h.putrequest('GET', baseurl + searchfor[0])
errcode, errmsg, headers = h.getreply()
if errcode == 200:
    f = h.getfile()
    pgp = os.popen('gpg --import ', 'w')
    pgp.write( # Print the raw HTML

More information about the Gnupg-devel mailing list