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