SSL Implementation
This commit is contained in:
@@ -1,5 +1,8 @@
|
|||||||
{
|
{
|
||||||
"Host": ":8080",
|
"Host": ":8080",
|
||||||
|
"Encrypted": true,
|
||||||
|
"SSLPrivateKey": "/home/ssl.key",
|
||||||
|
"SSLPublicKey": "/home/ssl.crt",
|
||||||
"Apps": [
|
"Apps": [
|
||||||
{
|
{
|
||||||
"ApplicationDisabled": false,
|
"ApplicationDisabled": false,
|
||||||
|
|||||||
@@ -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
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user