Jack Bates wrote: > Sander Marechal reports that he cannot use the CA certificates > distributed in the Debian ca-certificates package with mod_gnutls: > http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=511573 > > I confirmed that this behaviour is the same in mod_gnutls trunk revision > 403:
Hello, I believe the attached patch fixes the issue. It will be included in the next release. regards, Nikos
Index: include/mod_gnutls.h.in =================================================================== --- include/mod_gnutls.h.in (revision 402) +++ include/mod_gnutls.h.in (working copy) @@ -79,10 +79,6 @@ } mgs_dirconf_rec; -/* The maximum number of client CA certificates allowed. - */ -#define MAX_CA_CRTS 128 - /* The maximum number of certificates to send in a chain */ #define MAX_CHAIN_SIZE 8 @@ -111,7 +107,7 @@ const char* cache_config; const char* srp_tpasswd_file; const char* srp_tpasswd_conf_file; - gnutls_x509_crt_t ca_list[MAX_CA_CRTS]; + gnutls_x509_crt_t *ca_list; gnutls_openpgp_keyring_t pgp_list; unsigned int ca_list_size; int client_verify_mode; Index: src/gnutls_config.c =================================================================== --- src/gnutls_config.c (revision 402) +++ src/gnutls_config.c (working copy) @@ -398,6 +398,7 @@ return NULL; } +#define INIT_CA_SIZE 128 const char *mgs_set_client_ca_file(cmd_parms * parms, void *dummy, const char *arg) { @@ -419,16 +420,37 @@ "Client CA File '%s'", file); } - sc->ca_list_size = MAX_CA_CRTS; + sc->ca_list_size = INIT_CA_SIZE; + sc->ca_list = malloc(sc->ca_list_size * sizeof(*sc->ca_list)); + if (sc->ca_list == NULL) { + return apr_psprintf(parms->pool, "mod_gnutls: Memory allocation error"); + } + rv = gnutls_x509_crt_list_import(sc->ca_list, &sc->ca_list_size, - &data, GNUTLS_X509_FMT_PEM, - GNUTLS_X509_CRT_LIST_IMPORT_FAIL_IF_EXCEED); - if (rv < 0) { - return apr_psprintf(parms->pool, "GnuTLS: Failed to load " + &data, GNUTLS_X509_FMT_PEM, GNUTLS_X509_CRT_LIST_IMPORT_FAIL_IF_EXCEED); + if (rv < 0 && rv != GNUTLS_E_SHORT_MEMORY_BUFFER) { + return apr_psprintf(parms->pool, "GnuTLS: Failed to load " "Client CA File '%s': (%d) %s", file, rv, gnutls_strerror(rv)); } + + if (INIT_CA_SIZE < sc->ca_list_size) { + sc->ca_list = realloc(sc->ca_list, sc->ca_list_size*sizeof(*sc->ca_list)); + if (sc->ca_list == NULL) { + return apr_psprintf(parms->pool, "mod_gnutls: Memory allocation error"); + } + /* re-read */ + rv = gnutls_x509_crt_list_import(sc->ca_list, &sc->ca_list_size, + &data, GNUTLS_X509_FMT_PEM, 0); + + if (rv < 0) { + return apr_psprintf(parms->pool, "GnuTLS: Failed to load " + "Client CA File '%s': (%d) %s", file, rv, + gnutls_strerror(rv)); + } + } + apr_pool_destroy(spool); return NULL; } Index: NEWS =================================================================== --- NEWS (revision 402) +++ NEWS (working copy) @@ -1,5 +1,10 @@ -** Verison 0.5.4 (2009-01-04) +** Version 0.5.5 (unreleased) +- Removed limits on CA certificate loading. Reported by + Sander Marechal and Jack Bates. + +** Version 0.5.4 (2009-01-04) + - mod_gnutls.h: modified definition to extern to avoid compilation errors in darwin.