aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gnutls_config.c53
-rw-r--r--src/gnutls_hooks.c7
2 files changed, 49 insertions, 11 deletions
diff --git a/src/gnutls_config.c b/src/gnutls_config.c
index 22e8fbc..7b5a42b 100644
--- a/src/gnutls_config.c
+++ b/src/gnutls_config.c
@@ -72,10 +72,15 @@ const char *mgs_set_dh_file(cmd_parms * parms, void *dummy,
72 "DH params '%s'", file); 72 "DH params '%s'", file);
73 } 73 }
74 74
75 gnutls_dh_params_init(&sc->dh_params); 75 ret = gnutls_dh_params_init(&sc->dh_params);
76 if (ret < 0) {
77 return apr_psprintf(parms->pool, "GnuTLS: Failed to initialize"
78 ": (%d) %s", ret, gnutls_strerror(ret));
79 }
80
76 ret = 81 ret =
77 gnutls_dh_params_import_pkcs3(sc->dh_params, &data, GNUTLS_X509_FMT_PEM); 82 gnutls_dh_params_import_pkcs3(sc->dh_params, &data, GNUTLS_X509_FMT_PEM);
78 if (ret != 0) { 83 if (ret < 0) {
79 return apr_psprintf(parms->pool, "GnuTLS: Failed to Import " 84 return apr_psprintf(parms->pool, "GnuTLS: Failed to Import "
80 "DH params '%s': (%d) %s", file, ret, 85 "DH params '%s': (%d) %s", file, ret,
81 gnutls_strerror(ret)); 86 gnutls_strerror(ret));
@@ -107,7 +112,12 @@ const char *mgs_set_rsa_export_file(cmd_parms * parms, void *dummy,
107 "RSA params '%s'", file); 112 "RSA params '%s'", file);
108 } 113 }
109 114
110 gnutls_rsa_params_init(&sc->rsa_params); 115 ret = gnutls_rsa_params_init(&sc->rsa_params);
116 if (ret < 0) {
117 return apr_psprintf(parms->pool, "GnuTLS: Failed to initialize"
118 ": (%d) %s", ret, gnutls_strerror(ret));
119 }
120
111 ret = 121 ret =
112 gnutls_rsa_params_import_pkcs1(sc->rsa_params, &data, GNUTLS_X509_FMT_PEM); 122 gnutls_rsa_params_import_pkcs1(sc->rsa_params, &data, GNUTLS_X509_FMT_PEM);
113 if (ret != 0) { 123 if (ret != 0) {
@@ -141,7 +151,12 @@ const char *mgs_set_cert_file(cmd_parms * parms, void *dummy,
141 "Certificate '%s'", file); 151 "Certificate '%s'", file);
142 } 152 }
143 153
144 gnutls_x509_crt_init(&sc->cert_x509); 154 ret = gnutls_x509_crt_init(&sc->cert_x509);
155 if (ret < 0) {
156 return apr_psprintf(parms->pool, "GnuTLS: Failed to initialize"
157 ": (%d) %s", ret, gnutls_strerror(ret));
158 }
159
145 ret = 160 ret =
146 gnutls_x509_crt_import(sc->cert_x509, &data, GNUTLS_X509_FMT_PEM); 161 gnutls_x509_crt_import(sc->cert_x509, &data, GNUTLS_X509_FMT_PEM);
147 if (ret != 0) { 162 if (ret != 0) {
@@ -174,7 +189,12 @@ const char *mgs_set_key_file(cmd_parms * parms, void *dummy,
174 "Private Key '%s'", file); 189 "Private Key '%s'", file);
175 } 190 }
176 191
177 gnutls_x509_privkey_init(&sc->privkey_x509); 192 ret = gnutls_x509_privkey_init(&sc->privkey_x509);
193 if (ret < 0) {
194 return apr_psprintf(parms->pool, "GnuTLS: Failed to initialize"
195 ": (%d) %s", ret, gnutls_strerror(ret));
196 }
197
178 ret = 198 ret =
179 gnutls_x509_privkey_import(sc->privkey_x509, &data, 199 gnutls_x509_privkey_import(sc->privkey_x509, &data,
180 GNUTLS_X509_FMT_PEM); 200 GNUTLS_X509_FMT_PEM);
@@ -395,12 +415,27 @@ const char *mgs_set_priorities(cmd_parms * parms, void *dummy, const char *arg)
395void *mgs_config_server_create(apr_pool_t * p, server_rec * s) 415void *mgs_config_server_create(apr_pool_t * p, server_rec * s)
396{ 416{
397 mgs_srvconf_rec *sc = apr_pcalloc(p, sizeof(*sc)); 417 mgs_srvconf_rec *sc = apr_pcalloc(p, sizeof(*sc));
398 418 int ret;
419
399 sc->enabled = GNUTLS_ENABLED_FALSE; 420 sc->enabled = GNUTLS_ENABLED_FALSE;
400 421
401 gnutls_certificate_allocate_credentials(&sc->certs); 422 ret = gnutls_certificate_allocate_credentials(&sc->certs);
402 gnutls_anon_allocate_server_credentials(&sc->anon_creds); 423 if (ret < 0) {
403 gnutls_srp_allocate_server_credentials(&sc->srp_creds); 424 return apr_psprintf(p, "GnuTLS: Failed to initialize"
425 ": (%d) %s", ret, gnutls_strerror(ret));
426 }
427
428 ret = gnutls_anon_allocate_server_credentials(&sc->anon_creds);
429 if (ret < 0) {
430 return apr_psprintf(p, "GnuTLS: Failed to initialize"
431 ": (%d) %s", ret, gnutls_strerror(ret));
432 }
433
434 ret = gnutls_srp_allocate_server_credentials(&sc->srp_creds);
435 if (ret < 0) {
436 return apr_psprintf(p, "GnuTLS: Failed to initialize"
437 ": (%d) %s", ret, gnutls_strerror(ret));
438 }
404 439
405 sc->srp_tpasswd_conf_file = NULL; 440 sc->srp_tpasswd_conf_file = NULL;
406 sc->srp_tpasswd_file = NULL; 441 sc->srp_tpasswd_file = NULL;
diff --git a/src/gnutls_hooks.c b/src/gnutls_hooks.c
index 7b7e2b3..4364add 100644
--- a/src/gnutls_hooks.c
+++ b/src/gnutls_hooks.c
@@ -57,6 +57,7 @@ int
57mgs_hook_pre_config(apr_pool_t * pconf, 57mgs_hook_pre_config(apr_pool_t * pconf,
58 apr_pool_t * plog, apr_pool_t * ptemp) 58 apr_pool_t * plog, apr_pool_t * ptemp)
59{ 59{
60int ret;
60 61
61#if APR_HAS_THREADS 62#if APR_HAS_THREADS
62 ap_mpm_query(AP_MPMQ_IS_THREADED, &mpm_is_threaded); 63 ap_mpm_query(AP_MPMQ_IS_THREADED, &mpm_is_threaded);
@@ -67,8 +68,10 @@ mgs_hook_pre_config(apr_pool_t * pconf,
67 mpm_is_threaded = 0; 68 mpm_is_threaded = 0;
68#endif 69#endif
69 70
70 gnutls_global_init(); 71 ret = gnutls_global_init();
71 72 if (ret < 0) /* FIXME: can we print here? */
73 exit(ret);
74
72 apr_pool_cleanup_register(pconf, NULL, mgs_cleanup_pre_config, 75 apr_pool_cleanup_register(pconf, NULL, mgs_cleanup_pre_config,
73 apr_pool_cleanup_null); 76 apr_pool_cleanup_null);
74 77