1
0
mirror of https://github.com/moparisthebest/wget synced 2024-07-03 16:38:41 -04:00

The GNU TLS backend loads default root certificates.

This commit is contained in:
Giuseppe Scrivano 2010-07-05 19:27:16 +02:00
parent eb483c9f25
commit ec40efb27b
4 changed files with 45 additions and 0 deletions

View File

@ -1,3 +1,7 @@
2010-07-05 Giuseppe Scrivano <gscrivano@gnu.org>
* bootstrap.conf (gnulib_modules): Add `asprintf'.
2010-06-22 Giuseppe Scrivano <gscrivano@gnu.org>
* configure.ac: By default use GNU TLS not OpenSSL.

View File

@ -27,6 +27,7 @@ gnulib_modules="
accept
alloca
announce-gen
asprintf
bind
c-ctype
close

View File

@ -1,3 +1,8 @@
2010-07-05 Giuseppe Scrivano <gscrivano@gnu.org>
* gnutls.c (ssl_init): New local variables `ca_directory' and `dir'.
Load default root certificates under the `ca_directory' directory.
2010-07-03 Giuseppe Scrivano <gscrivano@gnu.org>
* gnutls.c (ssl_connect_wget): New local variable `allowed_protocols'.

View File

@ -37,6 +37,7 @@ as that of the covered work. */
#endif
#include <string.h>
#include <stdio.h>
#include <dirent.h>
#include <stdlib.h>
#include <gnutls/gnutls.h>
@ -61,8 +62,42 @@ static gnutls_certificate_credentials credentials;
bool
ssl_init ()
{
const char *ca_directory;
DIR *dir;
gnutls_global_init ();
gnutls_certificate_allocate_credentials (&credentials);
ca_directory = opt.ca_directory ? opt.ca_directory : "/etc/ssl/certs";
dir = opendir (ca_directory);
if (dir == NULL)
{
if (opt.ca_directory)
logprintf (LOG_NOTQUIET, _("ERROR: Cannot open directory %s.\n"),
opt.ca_directory);
}
else
{
struct dirent *dent;
while ((dent = readdir (dir)) != NULL)
{
struct stat st;
char *ca_file;
asprintf (&ca_file, "%s/%s", ca_directory, dent->d_name);
stat (ca_file, &st);
if (S_ISREG (st.st_mode))
gnutls_certificate_set_x509_trust_file (credentials, ca_file,
GNUTLS_X509_FMT_PEM);
free (ca_file);
}
closedir (dir);
}
if (opt.ca_cert)
gnutls_certificate_set_x509_trust_file (credentials, opt.ca_cert,
GNUTLS_X509_FMT_PEM);