1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

dirmngr: Let --gpgconf-list return the default keyserver.

* dirmngr/misc.c (get_default_keyserver): New.
* dirmngr/http.c: Include misc.h
(http_session_new): Use get_default_keyserver instead of hardwired
"hkps.pool.sks-keyservers.net".
* dirmngr/http-ntbtls.c (gnupg_http_tls_verify_cb): Ditto.
* dirmngr/dirmngr.c (main) <aGPGCongList>: Return default keyserver.

Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2017-03-02 17:58:00 +01:00
parent 0c4d0620d3
commit de6d8313f6
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
5 changed files with 37 additions and 5 deletions

View File

@ -1454,7 +1454,13 @@ main (int argc, char **argv)
es_printf ("ignore-ocsp-servic-url:%lu:\n", flags | GC_OPT_FLAG_NONE); es_printf ("ignore-ocsp-servic-url:%lu:\n", flags | GC_OPT_FLAG_NONE);
es_printf ("use-tor:%lu:\n", flags | GC_OPT_FLAG_NONE); es_printf ("use-tor:%lu:\n", flags | GC_OPT_FLAG_NONE);
es_printf ("keyserver:%lu:\n", flags | GC_OPT_FLAG_NONE);
filename_esc = percent_escape (get_default_keyserver (0), NULL);
es_printf ("keyserver:%lu:\"%s:\n", flags | GC_OPT_FLAG_DEFAULT,
filename_esc);
xfree (filename_esc);
es_printf ("nameserver:%lu:\n", flags | GC_OPT_FLAG_NONE); es_printf ("nameserver:%lu:\n", flags | GC_OPT_FLAG_NONE);
es_printf ("resolver-timeout:%lu:%u\n", es_printf ("resolver-timeout:%lu:%u\n",
flags | GC_OPT_FLAG_DEFAULT, 0); flags | GC_OPT_FLAG_DEFAULT, 0);

View File

@ -26,12 +26,12 @@
#include "dirmngr.h" #include "dirmngr.h"
#include "certcache.h" #include "certcache.h"
#include "validate.h" #include "validate.h"
#include "misc.h"
#ifdef HTTP_USE_NTBTLS #ifdef HTTP_USE_NTBTLS
# include <ntbtls.h> # include <ntbtls.h>
/* The callback used to verify the peer's certificate. */ /* The callback used to verify the peer's certificate. */
gpg_error_t gpg_error_t
gnupg_http_tls_verify_cb (void *opaque, gnupg_http_tls_verify_cb (void *opaque,
@ -77,11 +77,11 @@ gnupg_http_tls_verify_cb (void *opaque,
validate_flags = VALIDATE_FLAG_TLS; validate_flags = VALIDATE_FLAG_TLS;
/* Are we using the standard hkps:// pool use the dedicated /* If we are using the standard hkps:// pool use the dedicated
* root certificate. */ * root certificate. */
hostname = ntbtls_get_hostname (tls); hostname = ntbtls_get_hostname (tls);
if (hostname if (hostname
&& !ascii_strcasecmp (hostname, "hkps.pool.sks-keyservers.net")) && !ascii_strcasecmp (hostname, get_default_keyserver (1)))
{ {
validate_flags |= VALIDATE_FLAG_TRUST_HKPSPOOL; validate_flags |= VALIDATE_FLAG_TRUST_HKPSPOOL;
} }

View File

@ -100,6 +100,7 @@
#include "i18n.h" #include "i18n.h"
#include "dns-stuff.h" #include "dns-stuff.h"
#include "http.h" #include "http.h"
#include "misc.h"
#ifdef USE_NPTH #ifdef USE_NPTH
@ -726,7 +727,7 @@ http_session_new (http_session_t *r_session,
is_hkps_pool = (intended_hostname is_hkps_pool = (intended_hostname
&& !ascii_strcasecmp (intended_hostname, && !ascii_strcasecmp (intended_hostname,
"hkps.pool.sks-keyservers.net")); get_default_keyserver (1)));
/* If the user has not specified a CA list, and they are looking /* If the user has not specified a CA list, and they are looking
* for the hkps pool from sks-keyservers.net, then default to * for the hkps pool from sks-keyservers.net, then default to

View File

@ -30,6 +30,29 @@
#include "util.h" #include "util.h"
#include "misc.h" #include "misc.h"
/* Return a static string with the default keyserver. If NAME_ONLY is
* given only the name part is returned. */
const char *
get_default_keyserver (int name_only)
{
static const char *result;
if (!name_only)
return DIRMNGR_DEFAULT_KEYSERVER;
if (!result)
{
/* Strip the scheme from the constant. */
result = strstr (DIRMNGR_DEFAULT_KEYSERVER, "://");
log_assert (result && strlen (result) > 3);
result += 3;
/* Assert that there is no port given. */
log_assert (strchr (result, ':'));
}
return result;
}
/* Convert the hex encoded STRING back into binary and store the /* Convert the hex encoded STRING back into binary and store the
result into the provided buffer RESULT. The actual size of that result into the provided buffer RESULT. The actual size of that

View File

@ -21,6 +21,8 @@
#ifndef MISC_H #ifndef MISC_H
#define MISC_H #define MISC_H
const char *get_default_keyserver (int name_only);
/* Convert hex encoded string back to binary. */ /* Convert hex encoded string back to binary. */
size_t unhexify (unsigned char *result, const char *string); size_t unhexify (unsigned char *result, const char *string);