2010-06-09 18:53:51 +02:00
|
|
|
/* dirmngr.h - Common definitions for the dirmngr
|
2014-03-18 11:07:05 +01:00
|
|
|
* Copyright (C) 2002 Klarälvdalens Datakonsult AB
|
2015-03-28 17:23:56 +01:00
|
|
|
* Copyright (C) 2004, 2015 g10 Code GmbH
|
2014-03-18 11:07:05 +01:00
|
|
|
* Copyright (C) 2014 Werner Koch
|
2010-06-09 18:53:51 +02:00
|
|
|
*
|
2014-03-18 11:07:05 +01:00
|
|
|
* This file is part of GnuPG.
|
2010-06-09 18:53:51 +02:00
|
|
|
*
|
2014-03-18 11:07:05 +01:00
|
|
|
* GnuPG is free software; you can redistribute it and/or modify
|
2010-06-09 18:53:51 +02:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2014-03-18 11:07:05 +01:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2010-06-09 18:53:51 +02:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
2014-03-18 11:07:05 +01:00
|
|
|
* GnuPG is distributed in the hope that it will be useful,
|
2010-06-09 18:53:51 +02:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2016-11-05 12:02:19 +01:00
|
|
|
* along with this program; if not, see <https://www.gnu.org/licenses/>.
|
2017-11-13 16:09:32 +01:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: GPL-3.0+
|
2010-06-09 18:53:51 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef DIRMNGR_H
|
|
|
|
#define DIRMNGR_H
|
|
|
|
|
2010-07-16 15:19:45 +02:00
|
|
|
#include "./dirmngr-err.h"
|
2010-06-09 18:53:51 +02:00
|
|
|
#define map_assuan_err(a) \
|
|
|
|
map_assuan_err_with_source (GPG_ERR_SOURCE_DEFAULT, (a))
|
|
|
|
#include <errno.h>
|
|
|
|
#include <gcrypt.h>
|
|
|
|
#include <ksba.h>
|
|
|
|
|
|
|
|
#include "../common/util.h"
|
|
|
|
#include "../common/membuf.h"
|
|
|
|
#include "../common/sysutils.h" /* (gnupg_fd_t) */
|
2016-09-05 12:50:35 +02:00
|
|
|
#include "../common/asshelp.h" /* (assuan_context_t) */
|
2010-06-09 18:53:51 +02:00
|
|
|
#include "../common/i18n.h"
|
2018-07-25 14:35:04 +02:00
|
|
|
#include "dirmngr-status.h"
|
2015-10-18 20:07:44 +02:00
|
|
|
#include "http.h" /* (parsed_uri_t) */
|
2010-06-09 18:53:51 +02:00
|
|
|
|
|
|
|
/* This objects keeps information about a particular LDAP server and
|
|
|
|
is used as item of a single linked list of servers. */
|
2011-02-04 12:57:53 +01:00
|
|
|
struct ldap_server_s
|
2010-06-09 18:53:51 +02:00
|
|
|
{
|
|
|
|
struct ldap_server_s* next;
|
2011-02-04 12:57:53 +01:00
|
|
|
|
2010-06-09 18:53:51 +02:00
|
|
|
char *host;
|
|
|
|
int port;
|
|
|
|
char *user;
|
|
|
|
char *pass;
|
|
|
|
char *base;
|
2021-05-26 14:48:27 +02:00
|
|
|
unsigned int starttls:1; /* Use STARTTLS. */
|
|
|
|
unsigned int ldap_over_tls:1; /* Use LDAP over an TLS tunnel */
|
|
|
|
unsigned int ntds:1; /* Use Active Directory authentication. */
|
2010-06-09 18:53:51 +02:00
|
|
|
};
|
|
|
|
typedef struct ldap_server_s *ldap_server_t;
|
|
|
|
|
|
|
|
|
2011-01-10 14:30:17 +01:00
|
|
|
/* This objects is used to build a list of URI consisting of the
|
|
|
|
original and the parsed URI. */
|
|
|
|
struct uri_item_s
|
|
|
|
{
|
|
|
|
struct uri_item_s *next;
|
|
|
|
parsed_uri_t parsed_uri; /* The broken down URI. */
|
|
|
|
char uri[1]; /* The original URI. */
|
|
|
|
};
|
|
|
|
typedef struct uri_item_s *uri_item_t;
|
|
|
|
|
|
|
|
|
2010-06-09 18:53:51 +02:00
|
|
|
/* A list of fingerprints. */
|
|
|
|
struct fingerprint_list_s;
|
|
|
|
typedef struct fingerprint_list_s *fingerprint_list_t;
|
|
|
|
struct fingerprint_list_s
|
|
|
|
{
|
|
|
|
fingerprint_list_t next;
|
2021-10-06 10:31:41 +02:00
|
|
|
char binlen; /* If this is not 0 hexfpr actually carries a binary fpr. */
|
2010-06-09 18:53:51 +02:00
|
|
|
char hexfpr[20+20+1];
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* A large struct named "opt" to keep global flags. */
|
2020-02-10 16:37:34 +01:00
|
|
|
EXTERN_UNLESS_MAIN_MODULE
|
2011-02-04 12:57:53 +01:00
|
|
|
struct
|
2010-06-09 18:53:51 +02:00
|
|
|
{
|
|
|
|
unsigned int debug; /* debug flags (DBG_foo_VALUE) */
|
|
|
|
int verbose; /* verbosity level */
|
|
|
|
int quiet; /* be as quiet as possible */
|
|
|
|
int dry_run; /* don't change any persistent data */
|
|
|
|
int batch; /* batch mode */
|
2016-06-07 10:59:46 +02:00
|
|
|
const char *homedir_cache; /* Dir for cache files (/var/cache/dirmngr). */
|
2010-06-09 18:53:51 +02:00
|
|
|
|
|
|
|
char *config_filename; /* Name of a config file, which will be
|
|
|
|
reread on a HUP if it is not NULL. */
|
|
|
|
|
|
|
|
char *ldap_wrapper_program; /* Override value for the LDAP wrapper
|
|
|
|
program. */
|
|
|
|
char *http_wrapper_program; /* Override value for the HTTP wrapper
|
|
|
|
program. */
|
|
|
|
|
|
|
|
int running_detached; /* We are running in detached mode. */
|
2016-11-17 10:14:14 +01:00
|
|
|
int allow_version_check; /* --allow-version-check is active. */
|
2010-06-09 18:53:51 +02:00
|
|
|
|
|
|
|
int force; /* Force loading outdated CRLs. */
|
|
|
|
|
2017-06-08 09:30:48 +02:00
|
|
|
|
|
|
|
unsigned int connect_timeout; /* Timeout for connect. */
|
|
|
|
unsigned int connect_quick_timeout; /* Shorter timeout for connect. */
|
|
|
|
|
2010-06-09 18:53:51 +02:00
|
|
|
int disable_http; /* Do not use HTTP at all. */
|
|
|
|
int disable_ldap; /* Do not use LDAP at all. */
|
2017-04-03 20:56:12 +02:00
|
|
|
int disable_ipv4; /* Do not use legacy IP addresses. */
|
|
|
|
int disable_ipv6; /* Do not use standard IP addresses. */
|
2010-06-09 18:53:51 +02:00
|
|
|
int honor_http_proxy; /* Honor the http_proxy env variable. */
|
2015-04-21 17:14:53 +02:00
|
|
|
const char *http_proxy; /* The default HTTP proxy. */
|
2010-06-09 18:53:51 +02:00
|
|
|
const char *ldap_proxy; /* Use given LDAP proxy. */
|
|
|
|
int only_ldap_proxy; /* Only use the LDAP proxy; no fallback. */
|
|
|
|
int ignore_http_dp; /* Ignore HTTP CRL distribution points. */
|
|
|
|
int ignore_ldap_dp; /* Ignore LDAP CRL distribution points. */
|
|
|
|
int ignore_ocsp_service_url; /* Ignore OCSP service URLs as given in
|
|
|
|
the certificate. */
|
|
|
|
|
2021-10-06 10:31:41 +02:00
|
|
|
/* A list of fingerprints of certififcates we should completely
|
|
|
|
* ignore. These are all stored in binary format. */
|
|
|
|
fingerprint_list_t ignored_certs;
|
|
|
|
|
2010-06-09 18:53:51 +02:00
|
|
|
/* A list of certificate extension OIDs which are ignored so that
|
|
|
|
one can claim that a critical extension has been handled. One
|
|
|
|
OID per string. */
|
|
|
|
strlist_t ignored_cert_extensions;
|
|
|
|
|
|
|
|
int allow_ocsp; /* Allow using OCSP. */
|
|
|
|
|
|
|
|
int max_replies;
|
|
|
|
unsigned int ldaptimeout;
|
2011-02-04 12:57:53 +01:00
|
|
|
|
2010-06-09 18:53:51 +02:00
|
|
|
ldap_server_t ldapservers;
|
|
|
|
int add_new_ldapservers;
|
|
|
|
|
|
|
|
const char *ocsp_responder; /* Standard OCSP responder's URL. */
|
|
|
|
fingerprint_list_t ocsp_signer; /* The list of fingerprints with allowed
|
|
|
|
standard OCSP signer certificates. */
|
2011-02-04 12:57:53 +01:00
|
|
|
|
2010-06-09 18:53:51 +02:00
|
|
|
unsigned int ocsp_max_clock_skew; /* Allowed seconds of clocks skew. */
|
|
|
|
unsigned int ocsp_max_period; /* Seconds a response is at maximum
|
|
|
|
considered valid after thisUpdate. */
|
2011-02-04 12:57:53 +01:00
|
|
|
unsigned int ocsp_current_period; /* Seconds a response is considered
|
2010-06-09 18:53:51 +02:00
|
|
|
current after nextUpdate. */
|
2015-10-05 17:44:20 +02:00
|
|
|
|
2015-12-02 11:49:41 +01:00
|
|
|
strlist_t keyserver; /* List of default keyservers. */
|
2010-06-09 18:53:51 +02:00
|
|
|
} opt;
|
|
|
|
|
|
|
|
|
|
|
|
#define DBG_X509_VALUE 1 /* debug x.509 parsing */
|
|
|
|
#define DBG_CRYPTO_VALUE 4 /* debug low level crypto */
|
2016-12-19 09:41:15 +01:00
|
|
|
#define DBG_DNS_VALUE 16 /* debug DNS calls. */
|
2010-06-09 18:53:51 +02:00
|
|
|
#define DBG_MEMORY_VALUE 32 /* debug memory allocation stuff */
|
|
|
|
#define DBG_CACHE_VALUE 64 /* debug the caching */
|
|
|
|
#define DBG_MEMSTAT_VALUE 128 /* show memory statistics */
|
|
|
|
#define DBG_HASHING_VALUE 512 /* debug hashing operations */
|
2015-04-06 13:42:17 +02:00
|
|
|
#define DBG_IPC_VALUE 1024 /* debug assuan communication */
|
2016-12-19 09:41:15 +01:00
|
|
|
#define DBG_NETWORK_VALUE 2048 /* debug network I/O. */
|
2015-04-06 13:27:26 +02:00
|
|
|
#define DBG_LOOKUP_VALUE 8192 /* debug lookup details */
|
2017-02-23 20:14:16 +01:00
|
|
|
#define DBG_EXTPROG_VALUE 16384 /* debug external program calls */
|
2010-06-09 18:53:51 +02:00
|
|
|
|
|
|
|
#define DBG_X509 (opt.debug & DBG_X509_VALUE)
|
|
|
|
#define DBG_CRYPTO (opt.debug & DBG_CRYPTO_VALUE)
|
2016-12-19 09:41:15 +01:00
|
|
|
#define DBG_DNS (opt.debug & DBG_DNS_VALUE)
|
2010-06-09 18:53:51 +02:00
|
|
|
#define DBG_MEMORY (opt.debug & DBG_MEMORY_VALUE)
|
|
|
|
#define DBG_CACHE (opt.debug & DBG_CACHE_VALUE)
|
|
|
|
#define DBG_HASHING (opt.debug & DBG_HASHING_VALUE)
|
2015-04-06 13:42:17 +02:00
|
|
|
#define DBG_IPC (opt.debug & DBG_IPC_VALUE)
|
2016-12-19 09:41:15 +01:00
|
|
|
#define DBG_NETWORK (opt.debug & DBG_NETWORK_VALUE)
|
2015-04-06 13:27:26 +02:00
|
|
|
#define DBG_LOOKUP (opt.debug & DBG_LOOKUP_VALUE)
|
2017-02-23 20:14:16 +01:00
|
|
|
#define DBG_EXTPROG (opt.debug & DBG_EXTPROG_VALUE)
|
2010-06-09 18:53:51 +02:00
|
|
|
|
2017-02-17 16:39:48 +01:00
|
|
|
/* A simple list of certificate references. FIXME: Better use
|
|
|
|
certlist_t also for references (Store NULL at .cert) */
|
2010-06-09 18:53:51 +02:00
|
|
|
struct cert_ref_s
|
|
|
|
{
|
|
|
|
struct cert_ref_s *next;
|
|
|
|
unsigned char fpr[20];
|
|
|
|
};
|
|
|
|
typedef struct cert_ref_s *cert_ref_t;
|
|
|
|
|
2017-02-17 16:39:48 +01:00
|
|
|
|
2010-06-09 18:53:51 +02:00
|
|
|
/* Forward references; access only through server.c. */
|
|
|
|
struct server_local_s;
|
|
|
|
|
2017-02-19 10:36:43 +01:00
|
|
|
#if SIZEOF_UNSIGNED_LONG == 8
|
|
|
|
# define SERVER_CONTROL_MAGIC 0x6469726d6e677220
|
|
|
|
#else
|
|
|
|
# define SERVER_CONTROL_MAGIC 0x6469726d
|
|
|
|
#endif
|
|
|
|
|
2010-06-09 18:53:51 +02:00
|
|
|
/* Connection control structure. */
|
|
|
|
struct server_control_s
|
|
|
|
{
|
2017-02-19 10:36:43 +01:00
|
|
|
unsigned long magic;/* Always has SERVER_CONTROL_MAGIC. */
|
|
|
|
int refcount; /* Count additional references to this object. */
|
|
|
|
int no_server; /* We are not running under server control. */
|
|
|
|
int status_fd; /* Only for non-server mode. */
|
2010-06-09 18:53:51 +02:00
|
|
|
struct server_local_s *server_local;
|
|
|
|
int force_crl_refresh; /* Always load a fresh CRL. */
|
2011-02-04 12:57:53 +01:00
|
|
|
|
2010-06-09 18:53:51 +02:00
|
|
|
int check_revocations_nest_level; /* Internal to check_revovations. */
|
|
|
|
cert_ref_t ocsp_certs; /* Certificates from the current OCSP
|
|
|
|
response. */
|
|
|
|
|
|
|
|
int audit_events; /* Send audit events to client. */
|
2015-04-21 17:14:53 +02:00
|
|
|
char *http_proxy; /* The used http_proxy or NULL. */
|
2017-02-21 09:37:07 +01:00
|
|
|
|
2017-06-08 09:30:48 +02:00
|
|
|
unsigned int timeout; /* Timeout for connect calls in ms. */
|
|
|
|
|
2017-02-21 09:37:07 +01:00
|
|
|
unsigned int http_no_crl:1; /* Do not check CRLs for https. */
|
2010-06-09 18:53:51 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*-- dirmngr.c --*/
|
|
|
|
void dirmngr_exit( int ); /* Wrapper for exit() */
|
|
|
|
void dirmngr_init_default_ctrl (ctrl_t ctrl);
|
2015-04-21 17:14:53 +02:00
|
|
|
void dirmngr_deinit_default_ctrl (ctrl_t ctrl);
|
2010-08-12 13:43:46 +02:00
|
|
|
void dirmngr_sighup_action (void);
|
2016-10-26 22:37:06 +02:00
|
|
|
const char* dirmngr_get_current_socket_name (void);
|
2017-02-01 17:54:14 +01:00
|
|
|
int dirmngr_use_tor (void);
|
2014-03-18 11:07:05 +01:00
|
|
|
|
|
|
|
/*-- Various housekeeping functions. --*/
|
|
|
|
void ks_hkp_housekeeping (time_t curtime);
|
2017-01-23 13:07:54 +01:00
|
|
|
void ks_hkp_reload (void);
|
2018-09-11 06:54:49 +02:00
|
|
|
void ks_hkp_init (void);
|
2014-03-18 11:07:05 +01:00
|
|
|
|
2010-06-09 18:53:51 +02:00
|
|
|
/*-- server.c --*/
|
|
|
|
ldap_server_t get_ldapservers_from_ctrl (ctrl_t ctrl);
|
|
|
|
ksba_cert_t get_cert_local (ctrl_t ctrl, const char *issuer);
|
|
|
|
ksba_cert_t get_issuing_cert_local (ctrl_t ctrl, const char *issuer);
|
|
|
|
ksba_cert_t get_cert_local_ski (ctrl_t ctrl,
|
|
|
|
const char *name, ksba_sexp_t keyid);
|
|
|
|
gpg_error_t get_istrusted_from_client (ctrl_t ctrl, const char *hexfpr);
|
2016-09-05 12:50:35 +02:00
|
|
|
int dirmngr_assuan_log_monitor (assuan_context_t ctx, unsigned int cat,
|
|
|
|
const char *msg);
|
2017-11-14 13:42:18 +01:00
|
|
|
void start_command_handler (gnupg_fd_t fd, unsigned int session_id);
|
2010-06-09 18:53:51 +02:00
|
|
|
gpg_error_t dirmngr_tick (ctrl_t ctrl);
|
|
|
|
|
2017-02-19 10:36:43 +01:00
|
|
|
/*-- http-ntbtls.c --*/
|
|
|
|
/* Note that we don't use a callback for gnutls. */
|
|
|
|
|
|
|
|
gpg_error_t gnupg_http_tls_verify_cb (void *opaque,
|
|
|
|
http_t http,
|
|
|
|
http_session_t session,
|
|
|
|
unsigned int flags,
|
|
|
|
void *tls_context);
|
|
|
|
|
2010-06-09 18:53:51 +02:00
|
|
|
|
2016-11-16 21:22:39 +01:00
|
|
|
/*-- loadswdb.c --*/
|
|
|
|
gpg_error_t dirmngr_load_swdb (ctrl_t ctrl, int force);
|
|
|
|
|
2014-03-18 11:07:05 +01:00
|
|
|
|
2017-11-13 16:09:32 +01:00
|
|
|
/*-- domaininfo.c --*/
|
|
|
|
void domaininfo_print_stats (void);
|
|
|
|
int domaininfo_is_wkd_not_supported (const char *domain);
|
|
|
|
void domaininfo_set_no_name (const char *domain);
|
|
|
|
void domaininfo_set_wkd_supported (const char *domain);
|
|
|
|
void domaininfo_set_wkd_not_supported (const char *domain);
|
|
|
|
void domaininfo_set_wkd_not_found (const char *domain);
|
|
|
|
|
2017-11-14 13:42:18 +01:00
|
|
|
/*-- workqueue.c --*/
|
|
|
|
typedef const char *(*wqtask_t)(ctrl_t ctrl, const char *args);
|
|
|
|
|
|
|
|
void workqueue_dump_queue (ctrl_t ctrl);
|
|
|
|
gpg_error_t workqueue_add_task (wqtask_t func, const char *args,
|
|
|
|
unsigned int session_id, int need_network);
|
|
|
|
void workqueue_run_global_tasks (ctrl_t ctrl, int with_network);
|
|
|
|
void workqueue_run_post_session_tasks (unsigned int session_id);
|
|
|
|
|
2017-11-13 16:09:32 +01:00
|
|
|
|
|
|
|
|
2010-06-09 18:53:51 +02:00
|
|
|
#endif /*DIRMNGR_H*/
|