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/main.vala | |
parent | 2493262379dca2f01e07c9c83103240d67218fb3 (diff) | |
download | serial-barcode-scanner-06c4d13da6267d9c5698bec9521c76e3efdb1efa.tar.bz2 |
web: add tls support
Diffstat (limited to 'src/web/main.vala')
-rw-r--r-- | src/web/main.vala | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/web/main.vala b/src/web/main.vala index b5fdde3..dd354c5 100644 --- a/src/web/main.vala +++ b/src/web/main.vala @@ -20,19 +20,37 @@ public Config cfg; string templatedir; public static int main(string[] args) { + TlsCertificate? cert = null; + string certificate; + string privatekey; + uint port; + try { db = Bus.get_proxy_sync(BusType.SESSION, "io.mainframe.shopsystem.Database", "/io/mainframe/shopsystem/database"); pgp = Bus.get_proxy_sync(BusType.SESSION, "io.mainframe.shopsystem.PGP", "/io/mainframe/shopsystem/pgp"); cfg = Bus.get_proxy_sync(BusType.SESSION, "io.mainframe.shopsystem.Config", "/io/mainframe/shopsystem/config"); templatedir = cfg.get_string("WEB", "filepath"); + port = cfg.get_integer("WEB", "port"); + certificate = cfg.get_string("WEB", "cert"); + privatekey = cfg.get_string("WEB", "key"); } catch(IOError e) { error("IOError: %s\n", e.message); } catch(KeyFileError e) { error("KeyFileError: %s\n", e.message); } + stdout.printf("Web Server Port: %u\n", port); + stdout.printf("TLS certificate: %s\n", certificate); + stdout.printf("TLS private key: %s\n", privatekey); + /* attach WebServer to MainLoop */ - new WebServer(); + try { + if(certificate != "" && privatekey != "") + cert = new TlsCertificate.from_files(certificate, privatekey); + new WebServer(port, cert); + } catch(Error e) { + error("Could not start Webserver: %s\n", e.message); + } /* start MainLoop */ new MainLoop().run(); |