SSL Implementation

This commit is contained in:
Welington Sampaio
2016-03-03 08:37:00 -03:00
parent 51eacdcf51
commit 051da185e5
3 changed files with 17 additions and 2 deletions
+3
View File
@@ -1,5 +1,8 @@
{ {
"Host": ":8080", "Host": ":8080",
"Encrypted": true,
"SSLPrivateKey": "/home/ssl.key",
"SSLPublicKey": "/home/ssl.crt",
"Apps": [ "Apps": [
{ {
"ApplicationDisabled": false, "ApplicationDisabled": false,
+6
View File
@@ -14,6 +14,12 @@ type configFile struct {
Host string // The host, eg: :8080 will start on 0.0.0.0:8080 Host string // The host, eg: :8080 will start on 0.0.0.0:8080
User string User string
Password string Password string
// SSL Configurations
Encrypted bool
SSLPrivateKey string
SSLPublicKey string
Apps []*app Apps []*app
} }
+8 -2
View File
@@ -31,8 +31,14 @@ func Start(configfile string) error {
conf.Init() conf.Init()
router := newRouter() router := newRouter()
if err := http.ListenAndServe(conf.Host, router); err != nil { if conf.Encrypted {
return err 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 return nil