From 06c4d13da6267d9c5698bec9521c76e3efdb1efa Mon Sep 17 00:00:00 2001 From: Sebastian Reichel Date: Fri, 13 Feb 2015 16:20:36 +0100 Subject: web: add tls support --- src/web/web.vala | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/web/web.vala') diff --git a/src/web/web.vala b/src/web/web.vala index 1ff8acf..aa00586 100644 --- a/src/web/web.vala +++ b/src/web/web.vala @@ -987,8 +987,16 @@ public class WebServer { } } - public WebServer(int port = 8080) { - srv = new Soup.Server(Soup.SERVER_PORT, port); + public WebServer(uint port = 8080, TlsCertificate? cert = null) throws Error { + srv = new Soup.Server("tls-certificate", cert); + Soup.ServerListenOptions options = 0; + + if(cert != null) + options |= Soup.ServerListenOptions.HTTPS; + + if(!srv.listen_all(port, options)) { + throw new GLib.IOError.FAILED("Could not setup webserver!"); + } /* index */ srv.add_handler("/", handler_default); @@ -1022,7 +1030,5 @@ public class WebServer { srv.add_handler("/users", handler_users); srv.add_handler("/users/import", handler_user_import); srv.add_handler("/users/import-pgp", handler_user_pgp_import); - - srv.run_async(); } } -- cgit v1.2.3