From ad000200cbe6a9528da52812b53979038de24169 Mon Sep 17 00:00:00 2001 From: Thadeu Lima de Souza Cascardo Date: Tue, 7 Jul 2009 15:12:10 -0300 Subject: [PATCH] Added support for configuring certificate and key files. --- popproxy.c | 27 ++++++++++++++++++++++++++- popproxy.conf | 2 ++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/popproxy.c b/popproxy.c index f54c77c..a10b61b 100644 --- a/popproxy.c +++ b/popproxy.c @@ -181,6 +181,8 @@ int main (int argc, char **argv) gchar *port; gchar *server_address; gchar *server_port; + gchar *certfile; + gchar *ssl_keyfile; struct pop_address pop_address; gnutls_global_init (); @@ -211,6 +213,26 @@ int main (int argc, char **argv) exit (1); } + error = NULL; + certfile = g_key_file_get_string (keyfile, "global", "certfile", + &error); + if (certfile == NULL && error != NULL) + { + g_critical ("No certification file specified: %s.", + error->message); + g_error_free (error); + exit (1); + } + error = NULL; + ssl_keyfile = g_key_file_get_string (keyfile, "global", "keyfile", + &error); + if (ssl_keyfile == NULL && error != NULL) + { + ssl_keyfile = g_strdup (certfile); + g_error_free (error); + } + + error = NULL; conf_address = g_key_file_get_string (keyfile, "global", "address", &error); @@ -264,7 +286,10 @@ int main (int argc, char **argv) g_free (conf_address); g_free (port); - hc_conn_ssl_server_init_credentials ("cert.pem", "key.pem"); + hc_conn_ssl_server_init_credentials (certfile, ssl_keyfile); + + g_free (certfile); + g_free (ssl_keyfile); g_main_loop_run (g_main_loop_new (g_main_context_default (), TRUE)); diff --git a/popproxy.conf b/popproxy.conf index 90d8b27..d93b0eb 100644 --- a/popproxy.conf +++ b/popproxy.conf @@ -3,3 +3,5 @@ address = 0.0.0.0 port = 1100 server = 127.0.0.1 +certfile = "cert.pem" +keyfile = "key.pem" -- 2.20.1