diff options
author | Sebastian Reichel <sre@ring0.de> | 2015-02-13 16:20:36 +0100 |
---|---|---|
committer | Sebastian Reichel <sre@ring0.de> | 2015-02-13 16:20:36 +0100 |
commit | 06c4d13da6267d9c5698bec9521c76e3efdb1efa (patch) | |
tree | 8621b0d2fcc02937888a83c6830bba7a8ed79001 /src/web/web.vala | |
parent | 2493262379dca2f01e07c9c83103240d67218fb3 (diff) | |
download | serial-barcode-scanner-06c4d13da6267d9c5698bec9521c76e3efdb1efa.tar.bz2 |
web: add tls support
Diffstat (limited to 'src/web/web.vala')
-rw-r--r-- | src/web/web.vala | 14 |
1 files changed, 10 insertions, 4 deletions
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(); } } |