Added support for configuring certificate and key files.
authorThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Tue, 7 Jul 2009 18:12:10 +0000 (15:12 -0300)
committerThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Tue, 7 Jul 2009 18:12:10 +0000 (15:12 -0300)
popproxy.c
popproxy.conf

index f54c77c..a10b61b 100644 (file)
@@ -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));
 
index 90d8b27..d93b0eb 100644 (file)
@@ -3,3 +3,5 @@
 address = 0.0.0.0
 port = 1100
 server = 127.0.0.1
+certfile = "cert.pem"
+keyfile = "key.pem"