diff options
author | Nokis Mavrogiannopoulos | 2007-12-03 18:26:23 +0000 |
---|---|---|
committer | Nokis Mavrogiannopoulos | 2007-12-03 18:26:23 +0000 |
commit | 16d0fc76a6981f3f2562cdcade76179e9805dfd8 (patch) | |
tree | e43ac10d8d663abc12c958695243485398c1e6a9 /src/gnutls_config.c | |
parent | 7854add288a2b22a072d430460a21ebac547fb37 (diff) |
better handling of RSAFile and DHFile
Diffstat (limited to 'src/gnutls_config.c')
-rw-r--r-- | src/gnutls_config.c | 49 |
1 files changed, 46 insertions, 3 deletions
diff --git a/src/gnutls_config.c b/src/gnutls_config.c index 697dae1..22e8fbc 100644 --- a/src/gnutls_config.c +++ b/src/gnutls_config.c | |||
@@ -54,12 +54,34 @@ static int load_datum_from_file(apr_pool_t * pool, | |||
54 | const char *mgs_set_dh_file(cmd_parms * parms, void *dummy, | 54 | const char *mgs_set_dh_file(cmd_parms * parms, void *dummy, |
55 | const char *arg) | 55 | const char *arg) |
56 | { | 56 | { |
57 | int ret; | ||
58 | gnutls_datum_t data; | ||
59 | const char *file; | ||
60 | apr_pool_t *spool; | ||
57 | mgs_srvconf_rec *sc = | 61 | mgs_srvconf_rec *sc = |
58 | (mgs_srvconf_rec *) ap_get_module_config(parms->server-> | 62 | (mgs_srvconf_rec *) ap_get_module_config(parms->server-> |
59 | module_config, | 63 | module_config, |
60 | &gnutls_module); | 64 | &gnutls_module); |
61 | 65 | ||
62 | sc->dh_params_file = ap_server_root_relative(parms->pool, arg); | 66 | apr_pool_create(&spool, parms->pool); |
67 | |||
68 | file = ap_server_root_relative(spool, arg); | ||
69 | |||
70 | if (load_datum_from_file(spool, file, &data) != 0) { | ||
71 | return apr_psprintf(parms->pool, "GnuTLS: Error Reading " | ||
72 | "DH params '%s'", file); | ||
73 | } | ||
74 | |||
75 | gnutls_dh_params_init(&sc->dh_params); | ||
76 | ret = | ||
77 | gnutls_dh_params_import_pkcs3(sc->dh_params, &data, GNUTLS_X509_FMT_PEM); | ||
78 | if (ret != 0) { | ||
79 | return apr_psprintf(parms->pool, "GnuTLS: Failed to Import " | ||
80 | "DH params '%s': (%d) %s", file, ret, | ||
81 | gnutls_strerror(ret)); | ||
82 | } | ||
83 | |||
84 | apr_pool_destroy(spool); | ||
63 | 85 | ||
64 | return NULL; | 86 | return NULL; |
65 | } | 87 | } |
@@ -67,13 +89,34 @@ const char *mgs_set_dh_file(cmd_parms * parms, void *dummy, | |||
67 | const char *mgs_set_rsa_export_file(cmd_parms * parms, void *dummy, | 89 | const char *mgs_set_rsa_export_file(cmd_parms * parms, void *dummy, |
68 | const char *arg) | 90 | const char *arg) |
69 | { | 91 | { |
92 | int ret; | ||
93 | gnutls_datum_t data; | ||
94 | const char *file; | ||
95 | apr_pool_t *spool; | ||
70 | mgs_srvconf_rec *sc = | 96 | mgs_srvconf_rec *sc = |
71 | (mgs_srvconf_rec *) ap_get_module_config(parms->server-> | 97 | (mgs_srvconf_rec *) ap_get_module_config(parms->server-> |
72 | module_config, | 98 | module_config, |
73 | &gnutls_module); | 99 | &gnutls_module); |
74 | 100 | ||
75 | sc->rsa_params_file = ap_server_root_relative(parms->pool, arg); | 101 | apr_pool_create(&spool, parms->pool); |
102 | |||
103 | file = ap_server_root_relative(spool, arg); | ||
104 | |||
105 | if (load_datum_from_file(spool, file, &data) != 0) { | ||
106 | return apr_psprintf(parms->pool, "GnuTLS: Error Reading " | ||
107 | "RSA params '%s'", file); | ||
108 | } | ||
109 | |||
110 | gnutls_rsa_params_init(&sc->rsa_params); | ||
111 | ret = | ||
112 | gnutls_rsa_params_import_pkcs1(sc->rsa_params, &data, GNUTLS_X509_FMT_PEM); | ||
113 | if (ret != 0) { | ||
114 | return apr_psprintf(parms->pool, "GnuTLS: Failed to Import " | ||
115 | "RSA params '%s': (%d) %s", file, ret, | ||
116 | gnutls_strerror(ret)); | ||
117 | } | ||
76 | 118 | ||
119 | apr_pool_destroy(spool); | ||
77 | return NULL; | 120 | return NULL; |
78 | } | 121 | } |
79 | 122 | ||
@@ -103,7 +146,7 @@ const char *mgs_set_cert_file(cmd_parms * parms, void *dummy, | |||
103 | gnutls_x509_crt_import(sc->cert_x509, &data, GNUTLS_X509_FMT_PEM); | 146 | gnutls_x509_crt_import(sc->cert_x509, &data, GNUTLS_X509_FMT_PEM); |
104 | if (ret != 0) { | 147 | if (ret != 0) { |
105 | return apr_psprintf(parms->pool, "GnuTLS: Failed to Import " | 148 | return apr_psprintf(parms->pool, "GnuTLS: Failed to Import " |
106 | "Certificate'%s': (%d) %s", file, ret, | 149 | "Certificate '%s': (%d) %s", file, ret, |
107 | gnutls_strerror(ret)); | 150 | gnutls_strerror(ret)); |
108 | } | 151 | } |
109 | 152 | ||