summaryrefslogtreecommitdiffstats
path: root/src/web/main.vala
diff options
context:
space:
mode:
authorSebastian Reichel <sre@ring0.de>2015-02-13 16:20:36 +0100
committerSebastian Reichel <sre@ring0.de>2015-02-13 16:20:36 +0100
commit06c4d13da6267d9c5698bec9521c76e3efdb1efa (patch)
tree8621b0d2fcc02937888a83c6830bba7a8ed79001 /src/web/main.vala
parent2493262379dca2f01e07c9c83103240d67218fb3 (diff)
downloadserial-barcode-scanner-06c4d13da6267d9c5698bec9521c76e3efdb1efa.tar.bz2
web: add tls support
Diffstat (limited to 'src/web/main.vala')
-rw-r--r--src/web/main.vala20
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();