mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
Move http module from common/ to dirmngr/.
* common/http.c: Move to ../dirmngr/. * common/http.h: Move to ../dirmngr/. * common/t-http.c: Move to ../dirmngr/. * common/tls-ca.pem: Move to ../dirmngr/. * common/Makefile.am: Do not build libcommontls.a libcommontlsnpth.a. Remove http.c related stuff. * po/POTFILES.in: Move http.c to dirmngr/. * dirmngr/Makefile.am (EXTRA_DIST): Add tls-ca.pem. (module_maint_tests): New. (noinst_PROGRAMS): Add module_maint_tests. (dirmngr_SOURCES): Add http.c and http.h. (dirmngr_LDADD): Remove libcommontlsnpth. (t_common_ldadd): Ditto. (t_http_SOURCES, t_http_CFLAGS, t_http_LDADD): New. (t_ldap_parse_uri_SOURCES): Add http.c. (t_ldap_parse_uri_CFLAGS): Build without npth. ($(PROGRAMS)): Do not require libcommontls.a libcommontlsnpth.a. * dirmngr/dirmngr.h, dirmngr/ks-engine.h: Fix include of http.h. -- All network access is done via dirmngr and thus http.c should be there. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
128a456e77
commit
5aa1b392b1
9 changed files with 30 additions and 33 deletions
|
@ -19,7 +19,7 @@
|
|||
|
||||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
EXTRA_DIST = OAUTHORS ONEWS ChangeLog-2011
|
||||
EXTRA_DIST = OAUTHORS ONEWS ChangeLog-2011 tls-ca.pem
|
||||
|
||||
bin_PROGRAMS = dirmngr dirmngr-client
|
||||
|
||||
|
@ -27,7 +27,7 @@ if USE_LDAPWRAPPER
|
|||
libexec_PROGRAMS = dirmngr_ldap
|
||||
endif
|
||||
|
||||
noinst_PROGRAMS = $(module_tests)
|
||||
noinst_PROGRAMS = $(module_tests) $(module_maint_tests)
|
||||
TESTS = $(module_tests)
|
||||
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/common
|
||||
|
@ -62,6 +62,7 @@ dirmngr_SOURCES = dirmngr.c dirmngr.h server.c crlcache.c crlfetch.c \
|
|||
cdb.h cdblib.c misc.c dirmngr-err.h \
|
||||
ocsp.c ocsp.h validate.c validate.h \
|
||||
dns-cert.c dns-cert.h \
|
||||
http.c http.h \
|
||||
ks-action.c ks-action.h ks-engine.h \
|
||||
ks-engine-hkp.c ks-engine-http.c ks-engine-finger.c ks-engine-kdns.c
|
||||
|
||||
|
@ -75,7 +76,7 @@ ldaplibs =
|
|||
endif
|
||||
|
||||
|
||||
dirmngr_LDADD = $(libcommontlsnpth) $(libcommonpth) \
|
||||
dirmngr_LDADD = $(libcommonpth) \
|
||||
$(DNSLIBS) $(LIBASSUAN_LIBS) \
|
||||
$(LIBGCRYPT_LIBS) $(KSBA_LIBS) $(NPTH_LIBS) \
|
||||
$(NTBTLS_LIBS) $(LIBGNUTLS_LIBS) $(LIBINTL) $(LIBICONV)
|
||||
|
@ -108,8 +109,7 @@ no-libgcrypt.c : $(top_srcdir)/tools/no-libgcrypt.c
|
|||
|
||||
|
||||
t_common_src = t-support.h
|
||||
# We need libcommontls, because we use the http functions.
|
||||
t_common_ldadd = $(libcommontls) $(libcommon) no-libgcrypt.o \
|
||||
t_common_ldadd = $(libcommon) no-libgcrypt.o \
|
||||
$(GPG_ERROR_LIBS) $(NETLIBS) \
|
||||
$(NTBTLS_LIBS) $(LIBGNUTLS_LIBS) \
|
||||
$(DNSLIBS) $(LIBINTL) $(LIBICONV)
|
||||
|
@ -120,12 +120,28 @@ if USE_LDAP
|
|||
module_tests += t-ldap-parse-uri
|
||||
endif
|
||||
|
||||
if MAINTAINER_MODE
|
||||
module_maint_tests = t-http
|
||||
else
|
||||
module_maint_tests =
|
||||
endif
|
||||
|
||||
|
||||
# http tests
|
||||
t_http_SOURCES = t-http.c http.c
|
||||
t_http_CFLAGS = -DWITHOUT_NPTH=1 \
|
||||
$(LIBGCRYPT_CFLAGS) $(NTBTLS_CFLAGS) $(LIBGNUTLS_CFLAGS) \
|
||||
$(GPG_ERROR_CFLAGS)
|
||||
t_http_LDADD = $(t_common_ldadd) \
|
||||
$(NTBTLS_LIBS) $(LIBGNUTLS_LIBS) $(DNSLIBS)
|
||||
|
||||
t_ldap_parse_uri_SOURCES = \
|
||||
t-ldap-parse-uri.c ldap-parse-uri.c ldap-parse-uri.h \
|
||||
t-ldap-parse-uri.c ldap-parse-uri.c ldap-parse-uri.h http.c \
|
||||
$(ldap_url) $(t_common_src)
|
||||
t_ldap_parse_uri_CFLAGS = -DWITHOUT_NPTH=1
|
||||
t_ldap_parse_uri_LDADD = $(ldaplibs) $(t_common_ldadd)
|
||||
|
||||
t_dns_cert_SOURCES = t-dns-cert.c dns-cert.c
|
||||
t_dns_cert_LDADD = $(t_common_ldadd)
|
||||
|
||||
$(PROGRAMS) : $(libcommon) $(libcommonpth) $(libcommontls) $(libcommontlsnpth)
|
||||
$(PROGRAMS) : $(libcommon) $(libcommonpth)
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include "../common/membuf.h"
|
||||
#include "../common/sysutils.h" /* (gnupg_fd_t) */
|
||||
#include "../common/i18n.h"
|
||||
#include "../common/http.h" /* (parsed_uri_t) */
|
||||
#include "http.h" /* (parsed_uri_t) */
|
||||
|
||||
/* This objects keeps information about a particular LDAP server and
|
||||
is used as item of a single linked list of servers. */
|
||||
|
|
2777
dirmngr/http.c
Normal file
2777
dirmngr/http.c
Normal file
File diff suppressed because it is too large
Load diff
156
dirmngr/http.h
Normal file
156
dirmngr/http.h
Normal file
|
@ -0,0 +1,156 @@
|
|||
/* http.h - HTTP protocol handler
|
||||
* Copyright (C) 1999, 2000, 2001, 2003, 2006,
|
||||
* 2010 Free Software Foundation, Inc.
|
||||
* Copyright (C) 2015 g10 Code GmbH
|
||||
*
|
||||
* This file is part of GnuPG.
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or modify
|
||||
* it under the terms of either
|
||||
*
|
||||
* - the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* or
|
||||
*
|
||||
* - the GNU General Public License as published by the Free
|
||||
* Software Foundation; either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* or both in parallel, as here.
|
||||
*
|
||||
* This file is distributed in the hope that it will be useful,
|
||||
* 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
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef GNUPG_COMMON_HTTP_H
|
||||
#define GNUPG_COMMON_HTTP_H
|
||||
|
||||
#include <gpg-error.h>
|
||||
|
||||
struct uri_tuple_s
|
||||
{
|
||||
struct uri_tuple_s *next;
|
||||
const char *name; /* A pointer into name. */
|
||||
char *value; /* A pointer to value (a Nul is always appended). */
|
||||
size_t valuelen; /* The real length of the value; we need it
|
||||
because the value may contain embedded Nuls. */
|
||||
int no_value; /* True if no value has been given in the URL. */
|
||||
};
|
||||
typedef struct uri_tuple_s *uri_tuple_t;
|
||||
|
||||
struct parsed_uri_s
|
||||
{
|
||||
/* All these pointers point into BUFFER; most stuff is not escaped. */
|
||||
char *scheme; /* Pointer to the scheme string (always lowercase). */
|
||||
unsigned int is_http:1; /* This is a HTTP style URI. */
|
||||
unsigned int use_tls:1; /* Whether TLS should be used. */
|
||||
unsigned int opaque:1;/* Unknown scheme; PATH has the rest. */
|
||||
unsigned int v6lit:1; /* Host was given as a literal v6 address. */
|
||||
char *auth; /* username/password for basic auth. */
|
||||
char *host; /* Host (converted to lowercase). */
|
||||
unsigned short port; /* Port (always set if the host is set). */
|
||||
char *path; /* Path. */
|
||||
uri_tuple_t params; /* ";xxxxx" */
|
||||
uri_tuple_t query; /* "?xxx=yyy" */
|
||||
char buffer[1]; /* Buffer which holds a (modified) copy of the URI. */
|
||||
};
|
||||
typedef struct parsed_uri_s *parsed_uri_t;
|
||||
|
||||
struct uri_tuple_s *uri_query_lookup (parsed_uri_t uri, const char *key);
|
||||
|
||||
typedef enum
|
||||
{
|
||||
HTTP_REQ_GET = 1,
|
||||
HTTP_REQ_HEAD = 2,
|
||||
HTTP_REQ_POST = 3,
|
||||
HTTP_REQ_OPAQUE = 4 /* Internal use. */
|
||||
}
|
||||
http_req_t;
|
||||
|
||||
/* We put the flag values into an enum, so that gdb can display them. */
|
||||
enum
|
||||
{
|
||||
HTTP_FLAG_TRY_PROXY = 1, /* Try to use a proxy. */
|
||||
HTTP_FLAG_SHUTDOWN = 2, /* Close sending end after the request. */
|
||||
HTTP_FLAG_FORCE_TOR = 4, /* Force a TOR connection. */
|
||||
HTTP_FLAG_LOG_RESP = 8, /* Log the server respone. */
|
||||
HTTP_FLAG_FORCE_TLS = 16, /* Force the use of TLS. */
|
||||
HTTP_FLAG_IGNORE_CL = 32, /* Ignore content-length. */
|
||||
HTTP_FLAG_IGNORE_IPv4 = 64, /* Do not use IPv4. */
|
||||
HTTP_FLAG_IGNORE_IPv6 = 128 /* Do not use IPv6. */
|
||||
};
|
||||
|
||||
|
||||
struct http_session_s;
|
||||
typedef struct http_session_s *http_session_t;
|
||||
|
||||
struct http_context_s;
|
||||
typedef struct http_context_s *http_t;
|
||||
|
||||
void http_register_tls_callback (gpg_error_t (*cb)(http_t,http_session_t,int));
|
||||
void http_register_tls_ca (const char *fname);
|
||||
|
||||
gpg_error_t http_session_new (http_session_t *r_session,
|
||||
const char *tls_priority);
|
||||
http_session_t http_session_ref (http_session_t sess);
|
||||
void http_session_release (http_session_t sess);
|
||||
|
||||
void http_session_set_log_cb (http_session_t sess,
|
||||
void (*cb)(http_session_t, gpg_error_t,
|
||||
const char *,
|
||||
const void **, size_t *));
|
||||
|
||||
|
||||
gpg_error_t http_parse_uri (parsed_uri_t *ret_uri, const char *uri,
|
||||
int no_scheme_check);
|
||||
|
||||
void http_release_parsed_uri (parsed_uri_t uri);
|
||||
|
||||
gpg_error_t http_raw_connect (http_t *r_hd,
|
||||
const char *server, unsigned short port,
|
||||
unsigned int flags, const char *srvtag);
|
||||
|
||||
gpg_error_t http_open (http_t *r_hd, http_req_t reqtype,
|
||||
const char *url,
|
||||
const char *httphost,
|
||||
const char *auth,
|
||||
unsigned int flags,
|
||||
const char *proxy,
|
||||
http_session_t session,
|
||||
const char *srvtag,
|
||||
strlist_t headers);
|
||||
|
||||
void http_start_data (http_t hd);
|
||||
|
||||
gpg_error_t http_wait_response (http_t hd);
|
||||
|
||||
void http_close (http_t hd, int keep_read_stream);
|
||||
|
||||
gpg_error_t http_open_document (http_t *r_hd,
|
||||
const char *document,
|
||||
const char *auth,
|
||||
unsigned int flags,
|
||||
const char *proxy,
|
||||
http_session_t session,
|
||||
const char *srvtag,
|
||||
strlist_t headers);
|
||||
|
||||
estream_t http_get_read_ptr (http_t hd);
|
||||
estream_t http_get_write_ptr (http_t hd);
|
||||
unsigned int http_get_status_code (http_t hd);
|
||||
const char *http_get_tls_info (http_t hd, const char *what);
|
||||
const char *http_get_header (http_t hd, const char *name);
|
||||
const char **http_get_header_names (http_t hd);
|
||||
gpg_error_t http_verify_server_credentials (http_session_t sess);
|
||||
|
||||
char *http_escape_string (const char *string, const char *specials);
|
||||
char *http_escape_data (const void *data, size_t datalen, const char *specials);
|
||||
|
||||
|
||||
#endif /*GNUPG_COMMON_HTTP_H*/
|
|
@ -21,7 +21,7 @@
|
|||
#ifndef DIRMNGR_KS_ENGINE_H
|
||||
#define DIRMNGR_KS_ENGINE_H 1
|
||||
|
||||
#include "../common/http.h"
|
||||
#include "http.h"
|
||||
|
||||
/*-- ks-action.c --*/
|
||||
gpg_error_t ks_print_help (ctrl_t ctrl, const char *text);
|
||||
|
|
389
dirmngr/t-http.c
Normal file
389
dirmngr/t-http.c
Normal file
|
@ -0,0 +1,389 @@
|
|||
/* t-http.c
|
||||
* Copyright (C) 1999, 2001, 2002, 2003, 2004, 2006, 2009, 2010,
|
||||
* 2011 Free Software Foundation, Inc.
|
||||
* Copyright (C) 2014 Werner Koch
|
||||
*
|
||||
* This file is part of GnuPG.
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or modify
|
||||
* it under the terms of either
|
||||
*
|
||||
* - the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation; either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* or
|
||||
*
|
||||
* - the GNU General Public License as published by the Free
|
||||
* Software Foundation; either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* or both in parallel, as here.
|
||||
*
|
||||
* This file is distributed in the hope that it will be useful,
|
||||
* 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
|
||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "util.h"
|
||||
#include "logging.h"
|
||||
#include "http.h"
|
||||
|
||||
|
||||
#if HTTP_USE_NTBTLS
|
||||
# include <ntbtls.h>
|
||||
#elif HTTP_USE_GNUTLS
|
||||
# include <gnutls/gnutls.h> /* For init, logging, and deinit. */
|
||||
#endif /*HTTP_USE_GNUTLS*/
|
||||
|
||||
#define PGM "t-http"
|
||||
|
||||
static int verbose;
|
||||
static int debug;
|
||||
static int no_verify;
|
||||
|
||||
/* static void */
|
||||
/* read_dh_params (const char *fname) */
|
||||
/* { */
|
||||
/* gpg_error_t err; */
|
||||
/* int rc; */
|
||||
/* FILE *fp; */
|
||||
/* struct stat st; */
|
||||
/* char *buf; */
|
||||
/* size_t buflen; */
|
||||
/* gnutls_datum_t datum; */
|
||||
|
||||
/* fp = fopen (fname, "rb"); */
|
||||
/* if (!fp) */
|
||||
/* { */
|
||||
/* err = gpg_error_from_syserror (); */
|
||||
/* log_fatal ("can't open '%s': %s\n", fname, gpg_strerror (err)); */
|
||||
/* } */
|
||||
|
||||
/* if (fstat (fileno(fp), &st)) */
|
||||
/* { */
|
||||
/* err = gpg_error_from_syserror (); */
|
||||
/* log_fatal ("can't stat '%s': %s\n", fname, gpg_strerror (err)); */
|
||||
/* } */
|
||||
|
||||
/* buflen = st.st_size; */
|
||||
/* buf = xmalloc (buflen+1); */
|
||||
/* if (fread (buf, buflen, 1, fp) != 1) */
|
||||
/* { */
|
||||
/* err = gpg_error_from_syserror (); */
|
||||
/* log_fatal ("error reading '%s': %s\n", fname, gpg_strerror (err)); */
|
||||
/* } */
|
||||
/* fclose (fp); */
|
||||
|
||||
/* datum.size = buflen; */
|
||||
/* datum.data = buf; */
|
||||
|
||||
/* rc = gnutls_dh_params_import_pkcs3 (dh_params, &datum, GNUTLS_X509_FMT_PEM); */
|
||||
/* if (rc < 0) */
|
||||
/* log_fatal ("gnutls_dh_param_import failed: %s\n", gnutls_strerror (rc)); */
|
||||
|
||||
/* xfree (buf); */
|
||||
/* } */
|
||||
|
||||
|
||||
|
||||
#if HTTP_USE_GNUTLS
|
||||
static gpg_error_t
|
||||
verify_callback (http_t hd, http_session_t session, int reserved)
|
||||
{
|
||||
(void)hd;
|
||||
(void)reserved;
|
||||
return no_verify? 0 : http_verify_server_credentials (session);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if HTTP_USE_GNUTLS
|
||||
static void
|
||||
my_gnutls_log (int level, const char *text)
|
||||
{
|
||||
fprintf (stderr, "gnutls:L%d: %s", level, text);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Prepend FNAME with the srcdir environment variable's value and
|
||||
return an allocated filename. */
|
||||
static char *
|
||||
prepend_srcdir (const char *fname)
|
||||
{
|
||||
static const char *srcdir;
|
||||
char *result;
|
||||
|
||||
if (!srcdir && !(srcdir = getenv ("srcdir")))
|
||||
srcdir = ".";
|
||||
|
||||
result = xmalloc (strlen (srcdir) + 1 + strlen (fname) + 1);
|
||||
strcpy (result, srcdir);
|
||||
strcat (result, "/");
|
||||
strcat (result, fname);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
int last_argc = -1;
|
||||
gpg_error_t err;
|
||||
int rc;
|
||||
parsed_uri_t uri;
|
||||
uri_tuple_t r;
|
||||
http_t hd;
|
||||
int c;
|
||||
unsigned int my_http_flags = 0;
|
||||
int no_out = 0;
|
||||
int tls_dbg = 0;
|
||||
const char *cafile = NULL;
|
||||
http_session_t session = NULL;
|
||||
|
||||
gpgrt_init ();
|
||||
log_set_prefix (PGM, 1 | 4);
|
||||
if (argc)
|
||||
{ argc--; argv++; }
|
||||
while (argc && last_argc != argc )
|
||||
{
|
||||
last_argc = argc;
|
||||
if (!strcmp (*argv, "--"))
|
||||
{
|
||||
argc--; argv++;
|
||||
break;
|
||||
}
|
||||
else if (!strcmp (*argv, "--help"))
|
||||
{
|
||||
fputs ("usage: " PGM " URL\n"
|
||||
"Options:\n"
|
||||
" --verbose print timings etc.\n"
|
||||
" --debug flyswatter\n"
|
||||
" --gnutls-debug N use GNUTLS debug level N\n"
|
||||
" --cacert FNAME expect CA certificate in file FNAME\n"
|
||||
" --no-verify do not verify the certificate\n"
|
||||
" --force-tls use HTTP_FLAG_FORCE_TLS\n"
|
||||
" --force-tor use HTTP_FLAG_FORCE_TOR\n"
|
||||
" --no-out do not print the content\n",
|
||||
stdout);
|
||||
exit (0);
|
||||
}
|
||||
else if (!strcmp (*argv, "--verbose"))
|
||||
{
|
||||
verbose++;
|
||||
argc--; argv++;
|
||||
}
|
||||
else if (!strcmp (*argv, "--debug"))
|
||||
{
|
||||
verbose += 2;
|
||||
debug++;
|
||||
argc--; argv++;
|
||||
}
|
||||
else if (!strcmp (*argv, "--gnutls-debug"))
|
||||
{
|
||||
argc--; argv++;
|
||||
if (argc)
|
||||
{
|
||||
tls_dbg = atoi (*argv);
|
||||
argc--; argv++;
|
||||
}
|
||||
}
|
||||
else if (!strcmp (*argv, "--cacert"))
|
||||
{
|
||||
argc--; argv++;
|
||||
if (argc)
|
||||
{
|
||||
cafile = *argv;
|
||||
argc--; argv++;
|
||||
}
|
||||
}
|
||||
else if (!strcmp (*argv, "--no-verify"))
|
||||
{
|
||||
no_verify = 1;
|
||||
argc--; argv++;
|
||||
}
|
||||
else if (!strcmp (*argv, "--force-tls"))
|
||||
{
|
||||
my_http_flags |= HTTP_FLAG_FORCE_TLS;
|
||||
argc--; argv++;
|
||||
}
|
||||
else if (!strcmp (*argv, "--force-tor"))
|
||||
{
|
||||
my_http_flags |= HTTP_FLAG_FORCE_TOR;
|
||||
argc--; argv++;
|
||||
}
|
||||
else if (!strcmp (*argv, "--no-out"))
|
||||
{
|
||||
no_out = 1;
|
||||
argc--; argv++;
|
||||
}
|
||||
else if (!strncmp (*argv, "--", 2))
|
||||
{
|
||||
fprintf (stderr, PGM ": unknown option '%s'\n", *argv);
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
if (argc != 1)
|
||||
{
|
||||
fprintf (stderr, PGM ": no or too many URLS given\n");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
if (!cafile)
|
||||
cafile = prepend_srcdir ("tls-ca.pem");
|
||||
|
||||
#if HTTP_USE_NTBTLS
|
||||
|
||||
(void)err;
|
||||
|
||||
ntbtls_set_debug (tls_dbg, NULL, NULL);
|
||||
|
||||
#elif HTTP_USE_GNUTLS
|
||||
|
||||
rc = gnutls_global_init ();
|
||||
if (rc)
|
||||
log_error ("gnutls_global_init failed: %s\n", gnutls_strerror (rc));
|
||||
|
||||
http_register_tls_callback (verify_callback);
|
||||
http_register_tls_ca (cafile);
|
||||
|
||||
err = http_session_new (&session, NULL);
|
||||
if (err)
|
||||
log_error ("http_session_new failed: %s\n", gpg_strerror (err));
|
||||
|
||||
/* rc = gnutls_dh_params_init(&dh_params); */
|
||||
/* if (rc) */
|
||||
/* log_error ("gnutls_dh_params_init failed: %s\n", gnutls_strerror (rc)); */
|
||||
/* read_dh_params ("dh_param.pem"); */
|
||||
|
||||
/* rc = gnutls_certificate_set_x509_trust_file */
|
||||
/* (certcred, "ca.pem", GNUTLS_X509_FMT_PEM); */
|
||||
/* if (rc) */
|
||||
/* log_error ("gnutls_certificate_set_x509_trust_file failed: %s\n", */
|
||||
/* gnutls_strerror (rc)); */
|
||||
|
||||
/* gnutls_certificate_set_dh_params (certcred, dh_params); */
|
||||
|
||||
gnutls_global_set_log_function (my_gnutls_log);
|
||||
if (tls_dbg)
|
||||
gnutls_global_set_log_level (tls_dbg);
|
||||
|
||||
#endif /*HTTP_USE_GNUTLS*/
|
||||
|
||||
rc = http_parse_uri (&uri, *argv, 1);
|
||||
if (rc)
|
||||
{
|
||||
log_error ("'%s': %s\n", *argv, gpg_strerror (rc));
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf ("Scheme: %s\n", uri->scheme);
|
||||
if (uri->opaque)
|
||||
printf ("Value : %s\n", uri->path);
|
||||
else
|
||||
{
|
||||
printf ("Auth : %s\n", uri->auth? uri->auth:"[none]");
|
||||
printf ("Host : %s\n", uri->host);
|
||||
printf ("Port : %u\n", uri->port);
|
||||
printf ("Path : %s\n", uri->path);
|
||||
for (r = uri->params; r; r = r->next)
|
||||
{
|
||||
printf ("Params: %s", r->name);
|
||||
if (!r->no_value)
|
||||
{
|
||||
printf ("=%s", r->value);
|
||||
if (strlen (r->value) != r->valuelen)
|
||||
printf (" [real length=%d]", (int) r->valuelen);
|
||||
}
|
||||
putchar ('\n');
|
||||
}
|
||||
for (r = uri->query; r; r = r->next)
|
||||
{
|
||||
printf ("Query : %s", r->name);
|
||||
if (!r->no_value)
|
||||
{
|
||||
printf ("=%s", r->value);
|
||||
if (strlen (r->value) != r->valuelen)
|
||||
printf (" [real length=%d]", (int) r->valuelen);
|
||||
}
|
||||
putchar ('\n');
|
||||
}
|
||||
printf ("TLS : %s\n",
|
||||
uri->use_tls? "yes":
|
||||
(my_http_flags&HTTP_FLAG_FORCE_TLS)? "forced" : "no");
|
||||
printf ("Tor : %s\n",
|
||||
(my_http_flags&HTTP_FLAG_FORCE_TOR)? "yes" : "no");
|
||||
|
||||
}
|
||||
fflush (stdout);
|
||||
http_release_parsed_uri (uri);
|
||||
uri = NULL;
|
||||
|
||||
rc = http_open_document (&hd, *argv, NULL, my_http_flags,
|
||||
NULL, session, NULL, NULL);
|
||||
if (rc)
|
||||
{
|
||||
log_error ("can't get '%s': %s\n", *argv, gpg_strerror (rc));
|
||||
return 1;
|
||||
}
|
||||
log_info ("open_http_document succeeded; status=%u\n",
|
||||
http_get_status_code (hd));
|
||||
|
||||
{
|
||||
const char **names;
|
||||
int i;
|
||||
|
||||
names = http_get_header_names (hd);
|
||||
if (!names)
|
||||
log_fatal ("http_get_header_names failed: %s\n",
|
||||
gpg_strerror (gpg_error_from_syserror ()));
|
||||
for (i = 0; names[i]; i++)
|
||||
printf ("HDR: %s: %s\n", names[i], http_get_header (hd, names[i]));
|
||||
xfree (names);
|
||||
}
|
||||
fflush (stdout);
|
||||
|
||||
switch (http_get_status_code (hd))
|
||||
{
|
||||
case 200:
|
||||
case 400:
|
||||
case 401:
|
||||
case 403:
|
||||
case 404:
|
||||
{
|
||||
unsigned long count = 0;
|
||||
while ((c = es_getc (http_get_read_ptr (hd))) != EOF)
|
||||
{
|
||||
count++;
|
||||
if (!no_out)
|
||||
putchar (c);
|
||||
}
|
||||
log_info ("Received bytes: %lu\n", count);
|
||||
}
|
||||
break;
|
||||
case 301:
|
||||
case 302:
|
||||
case 307:
|
||||
log_info ("Redirected to: %s\n", http_get_header (hd, "Location"));
|
||||
break;
|
||||
}
|
||||
http_close (hd, 0);
|
||||
|
||||
http_session_release (session);
|
||||
#ifdef HTTP_USE_GNUTLS
|
||||
gnutls_global_deinit ();
|
||||
#endif /*HTTP_USE_GNUTLS*/
|
||||
|
||||
return 0;
|
||||
}
|
30
dirmngr/tls-ca.pem
Normal file
30
dirmngr/tls-ca.pem
Normal file
|
@ -0,0 +1,30 @@
|
|||
Issuer ...: /CN=UTN-USERFirst-Hardware/OU=http:\x2f\x2fwww.usertrust.com/O=The USERTRUST Network/L=Salt Lake City/ST=UT/C=US
|
||||
Serial ...: 44BE0C8B500024B411D3362AFE650AFD
|
||||
Subject ..: /CN=UTN-USERFirst-Hardware/OU=http:\x2f\x2fwww.usertrust.com/O=The USERTRUST Network/L=Salt Lake City/ST=UT/C=US
|
||||
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIEdDCCA1ygAwIBAgIQRL4Mi1AAJLQR0zYq/mUK/TANBgkqhkiG9w0BAQUFADCB
|
||||
lzELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAlVUMRcwFQYDVQQHEw5TYWx0IExha2Ug
|
||||
Q2l0eTEeMBwGA1UEChMVVGhlIFVTRVJUUlVTVCBOZXR3b3JrMSEwHwYDVQQLExho
|
||||
dHRwOi8vd3d3LnVzZXJ0cnVzdC5jb20xHzAdBgNVBAMTFlVUTi1VU0VSRmlyc3Qt
|
||||
SGFyZHdhcmUwHhcNOTkwNzA5MTgxMDQyWhcNMTkwNzA5MTgxOTIyWjCBlzELMAkG
|
||||
A1UEBhMCVVMxCzAJBgNVBAgTAlVUMRcwFQYDVQQHEw5TYWx0IExha2UgQ2l0eTEe
|
||||
MBwGA1UEChMVVGhlIFVTRVJUUlVTVCBOZXR3b3JrMSEwHwYDVQQLExhodHRwOi8v
|
||||
d3d3LnVzZXJ0cnVzdC5jb20xHzAdBgNVBAMTFlVUTi1VU0VSRmlyc3QtSGFyZHdh
|
||||
cmUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCx98M4P7Sof885glFn
|
||||
0G2f0v9Y8+efK+wNiVSZuTiZFvfgIXlIwrthdBKWHTxqctU8EGc6Oe0rE81m65UJ
|
||||
M6Rsl7HoxuzBdXmcRl6Nq9Bq/bkqVRcQVLMZ8Jr28bFdtqdt++BxF2uiiPsA3/4a
|
||||
MXcMmgF6sTLjKwEHOG7DpV4jvEWbe1DByTCP2+UretNb+zNAHqDVmBe8i4fDidNd
|
||||
oI6yqqr2jmmIBsX6iSHzCJ1pLgkzmykNRg+MzEk0sGlRvfkGzWitZky8PqxhvQqI
|
||||
DsjfPe58BEydCl5rkdbux+0ojatNh4lz0G6k0B4WixThdkQDf2Os5M1JnMWS9Ksy
|
||||
oUhbAgMBAAGjgbkwgbYwCwYDVR0PBAQDAgHGMA8GA1UdEwEB/wQFMAMBAf8wHQYD
|
||||
VR0OBBYEFKFyXyYbKJhDlV0HN9WFlp1L0sNFMEQGA1UdHwQ9MDswOaA3oDWGM2h0
|
||||
dHA6Ly9jcmwudXNlcnRydXN0LmNvbS9VVE4tVVNFUkZpcnN0LUhhcmR3YXJlLmNy
|
||||
bDAxBgNVHSUEKjAoBggrBgEFBQcDAQYIKwYBBQUHAwUGCCsGAQUFBwMGBggrBgEF
|
||||
BQcDBzANBgkqhkiG9w0BAQUFAAOCAQEARxkP3nTGmZev/K0oXnWO6y1n7k57K9cM
|
||||
//bey1WiCuFMVGWTYGufEpytXoMs61quwOQt9ABjHbjAbPLPSbtNk28Gpgoiskli
|
||||
CE7/yMgUsogWXecB5BKV5UU0s4tpvc+0hY91UZ59Ojg6FEgSxvunOxqNDYJAB+gE
|
||||
CJChicsZUN/KHAG8HQQZexB2lzvukJDKxA4fFm517zP4029bHpbj4HR3dHuKom4t
|
||||
3XbWOTCC8KucUvIqx69JXn7HaOWCgchqJ/kniCrVWFCVH/A7HFe7fRQ5YiuayZSS
|
||||
KqMiDP+JJn1fIytH1xUdqWqeUQ0qUZ6B+dQ7XnASfxAynB67nfhmqA==
|
||||
-----END CERTIFICATE-----
|
Loading…
Add table
Add a link
Reference in a new issue