From 2c79a2832cd3cbc1c09f4f7a7b2653ba6cbd2845 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Tue, 8 Feb 2011 21:11:19 +0100 Subject: Add finger support to dirmngr. The basic network code from http.c is used for finger. This keeps the network related code at one place and we are able to use the somewhat matured code form http.c. Unfortunately I had to enhance the http code for more robustness and probably introduced new bugs. Test this code using gpg --fetch-key finger:wk@g10code.com (I might be the last user of finger ;-) --- dirmngr/ks-action.c | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) (limited to 'dirmngr/ks-action.c') diff --git a/dirmngr/ks-action.c b/dirmngr/ks-action.c index 50f0d5063..dff49979f 100644 --- a/dirmngr/ks-action.c +++ b/dirmngr/ks-action.c @@ -132,7 +132,7 @@ ks_action_get (ctrl_t ctrl, strlist_t patterns, estream_t outfp) else { err = copy_stream (infp, outfp); - /* Reading from the keyserver should nver fail, thus + /* Reading from the keyserver should never fail, thus return this error. */ es_fclose (infp); infp = NULL; @@ -149,6 +149,49 @@ ks_action_get (ctrl_t ctrl, strlist_t patterns, estream_t outfp) } +/* Retrive keys from URL and write the result to the provided output + stream OUTFP. */ +gpg_error_t +ks_action_fetch (ctrl_t ctrl, const char *url, estream_t outfp) +{ + gpg_error_t err = 0; + estream_t infp; + parsed_uri_t parsed_uri; /* The broken down URI. */ + + if (!url) + return gpg_error (GPG_ERR_INV_URI); + + err = http_parse_uri (&parsed_uri, url, 1); + if (err) + return err; + + if (parsed_uri->is_http) + { + err = gpg_error (GPG_ERR_NOT_IMPLEMENTED); + } + else if (!parsed_uri->opaque) + { + err = gpg_error (GPG_ERR_INV_URI); + } + else if (!strcmp (parsed_uri->scheme, "finger")) + { + err = ks_finger_get (ctrl, parsed_uri, &infp); + if (!err) + { + err = copy_stream (infp, outfp); + /* Reading from the finger serrver should not fail, thus + return this error. */ + es_fclose (infp); + } + } + else + err = gpg_error (GPG_ERR_INV_URI); + + http_release_parsed_uri (parsed_uri); + return err; +} + + /* Send an OpenPGP key to all keyservers. The key in {DATA,DATALEN} is expected in OpenPGP binary transport format. */ -- cgit v1.2.3