aboutsummaryrefslogtreecommitdiffstats
path: root/src/gnutls_config.c
diff options
context:
space:
mode:
authorGravatar Nikos Mavrogiannopoulos 2007-12-15 13:26:01 +0000
committerGravatar Nokis Mavrogiannopoulos 2007-12-15 13:26:01 +0000
commite5bbda4df989848cbcd92263dd4b11a99b019b4f (patch)
tree721754cdff0987366b835feb26b4b48e89ec0542 /src/gnutls_config.c
parentd2439b92fc87095f0288d9bc1aa5cf2621f0eac3 (diff)
Initial support for openpgp keys
Diffstat (limited to 'src/gnutls_config.c')
-rw-r--r--src/gnutls_config.c111
1 files changed, 111 insertions, 0 deletions
diff --git a/src/gnutls_config.c b/src/gnutls_config.c
index 8d6308a..4dccd08 100644
--- a/src/gnutls_config.c
+++ b/src/gnutls_config.c
@@ -202,6 +202,85 @@ const char *mgs_set_key_file(cmd_parms * parms, void *dummy,
202 return NULL; 202 return NULL;
203} 203}
204 204
205const char *mgs_set_pgpcert_file(cmd_parms * parms, void *dummy,
206 const char *arg)
207{
208 int ret;
209 gnutls_datum_t data;
210 const char *file;
211 apr_pool_t *spool;
212 mgs_srvconf_rec *sc =
213 (mgs_srvconf_rec *) ap_get_module_config(parms->server->
214 module_config,
215 &gnutls_module);
216 apr_pool_create(&spool, parms->pool);
217
218 file = ap_server_root_relative(spool, arg);
219
220 if (load_datum_from_file(spool, file, &data) != 0) {
221 return apr_psprintf(parms->pool, "GnuTLS: Error Reading "
222 "Certificate '%s'", file);
223 }
224
225 ret = gnutls_openpgp_crt_init( &sc->cert_pgp);
226 if (ret < 0) {
227 return apr_psprintf(parms->pool, "GnuTLS: Failed to Init "
228 "PGP Certificate: (%d) %s", ret,
229 gnutls_strerror(ret));
230 }
231
232
233 ret =
234 gnutls_openpgp_crt_import(sc->cert_pgp, &data, GNUTLS_OPENPGP_FMT_BASE64);
235 if (ret < 0) {
236 return apr_psprintf(parms->pool, "GnuTLS: Failed to Import "
237 "PGP Certificate '%s': (%d) %s", file, ret,
238 gnutls_strerror(ret));
239 }
240
241 apr_pool_destroy(spool);
242 return NULL;
243}
244
245const char *mgs_set_pgpkey_file(cmd_parms * parms, void *dummy,
246 const char *arg)
247{
248 int ret;
249 gnutls_datum_t data;
250 const char *file;
251 apr_pool_t *spool;
252 mgs_srvconf_rec *sc =
253 (mgs_srvconf_rec *) ap_get_module_config(parms->server->
254 module_config,
255 &gnutls_module);
256 apr_pool_create(&spool, parms->pool);
257
258 file = ap_server_root_relative(spool, arg);
259
260 if (load_datum_from_file(spool, file, &data) != 0) {
261 return apr_psprintf(parms->pool, "GnuTLS: Error Reading "
262 "Private Key '%s'", file);
263 }
264
265 ret = gnutls_openpgp_privkey_init(&sc->privkey_pgp);
266 if (ret < 0) {
267 return apr_psprintf(parms->pool, "GnuTLS: Failed to initialize"
268 ": (%d) %s", ret, gnutls_strerror(ret));
269 }
270
271 ret =
272 gnutls_openpgp_privkey_import(sc->privkey_pgp, &data,
273 GNUTLS_OPENPGP_FMT_BASE64, NULL, 0);
274 if (ret != 0) {
275 return apr_psprintf(parms->pool, "GnuTLS: Failed to Import "
276 "PGP Private Key '%s': (%d) %s", file, ret,
277 gnutls_strerror(ret));
278 }
279 apr_pool_destroy(spool);
280 return NULL;
281}
282
283
205const char *mgs_set_srp_tpasswd_file(cmd_parms * parms, void *dummy, 284const char *mgs_set_srp_tpasswd_file(cmd_parms * parms, void *dummy,
206 const char *arg) 285 const char *arg)
207{ 286{
@@ -350,6 +429,38 @@ const char *mgs_set_client_ca_file(cmd_parms * parms, void *dummy,
350 return NULL; 429 return NULL;
351} 430}
352 431
432const char *mgs_set_keyring_file(cmd_parms * parms, void *dummy,
433 const char *arg)
434{
435 int rv;
436 const char *file;
437 apr_pool_t *spool;
438 gnutls_datum_t data;
439
440 mgs_srvconf_rec *sc =
441 (mgs_srvconf_rec *) ap_get_module_config(parms->server->
442 module_config,
443 &gnutls_module);
444 apr_pool_create(&spool, parms->pool);
445
446 file = ap_server_root_relative(spool, arg);
447
448 if (load_datum_from_file(spool, file, &data) != 0) {
449 return apr_psprintf(parms->pool, "GnuTLS: Error Reading "
450 "Keyring File '%s'", file);
451 }
452
453 rv = gnutls_openpgp_keyring_import(sc->pgp_list, &data, GNUTLS_OPENPGP_FMT_BASE64);
454 if (rv < 0) {
455 return apr_psprintf(parms->pool, "GnuTLS: Failed to load "
456 "Keyring File '%s': (%d) %s", file, rv,
457 gnutls_strerror(rv));
458 }
459
460 apr_pool_destroy(spool);
461 return NULL;
462}
463
353const char *mgs_set_enabled(cmd_parms * parms, void *dummy, 464const char *mgs_set_enabled(cmd_parms * parms, void *dummy,
354 const char *arg) 465 const char *arg)
355{ 466{