From 051da185e5132799a24134b174d389f50d2a97af Mon Sep 17 00:00:00 2001 From: Welington Sampaio Date: Thu, 3 Mar 2016 08:37:00 -0300 Subject: [PATCH] SSL Implementation --- ipe/config-example.json | 3 +++ ipe/config.go | 6 ++++++ ipe/ipe.go | 10 ++++++++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/ipe/config-example.json b/ipe/config-example.json index 4a29451..d86cabe 100644 --- a/ipe/config-example.json +++ b/ipe/config-example.json @@ -1,5 +1,8 @@ { "Host": ":8080", + "Encrypted": true, + "SSLPrivateKey": "/home/ssl.key", + "SSLPublicKey": "/home/ssl.crt", "Apps": [ { "ApplicationDisabled": false, diff --git a/ipe/config.go b/ipe/config.go index 85bf8e3..c12946c 100644 --- a/ipe/config.go +++ b/ipe/config.go @@ -14,6 +14,12 @@ type configFile struct { Host string // The host, eg: :8080 will start on 0.0.0.0:8080 User string Password string + + // SSL Configurations + Encrypted bool + SSLPrivateKey string + SSLPublicKey string + Apps []*app } diff --git a/ipe/ipe.go b/ipe/ipe.go index 4e5db24..0bc6142 100644 --- a/ipe/ipe.go +++ b/ipe/ipe.go @@ -31,8 +31,14 @@ func Start(configfile string) error { conf.Init() router := newRouter() - if err := http.ListenAndServe(conf.Host, router); err != nil { - return err + if conf.Encrypted { + if err := http.ListenAndServeTLS(conf.Host, conf.SSLPublicKey, conf.SSLPrivateKey, router); err != nil { + return err + } + }else{ + if err := http.ListenAndServe(conf.Host, router); err != nil { + return err + } } return nil