Added TLS and HTTP/2 support
In order to use TLS and HTTP/2, add the necessary certificate and the key to the staticFiles.zip file and configure Ocean to enable it.
This commit is contained in:
1 parent
4fcb0d9ca2
commit
4ef6e64a45
5 files changed
+116
-3
No files matched your search
@@ -3,10 +3,12 @@ package StaticFiles
|
||||
import (
|
||||
"archive/zip"
|
||||
"bytes"
|
||||
"github.com/SommerEngineering/Ocean/ConfigurationDB"
|
||||
"github.com/SommerEngineering/Ocean/Log"
|
||||
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||
"github.com/SommerEngineering/Ocean/Shutdown"
|
||||
"io/ioutil"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Try to read a static file.
|
||||
@@ -17,6 +19,40 @@ func FindAndReadFile(filename string) (result []byte) {
|
||||
return
|
||||
}
|
||||
|
||||
//
|
||||
// Ensure that the TLS keys are secure and save:
|
||||
//
|
||||
if strings.ToLower(filename) == strings.ToLower(ConfigurationDB.Read(`AdminWebServerTLSCertificateName`)) {
|
||||
Log.LogFull(senderName, LM.CategorySYSTEM, LM.LevelSECURITY, LM.SeverityNone, LM.ImpactNone, LM.MessageNameREQUEST, `Someone tried to read the TLS certificate of the admin server. The attempt was inhibited.`)
|
||||
return
|
||||
}
|
||||
|
||||
if strings.ToLower(filename) == strings.ToLower(ConfigurationDB.Read(`AdminWebServerTLSPrivateKey`)) {
|
||||
Log.LogFull(senderName, LM.CategorySYSTEM, LM.LevelSECURITY, LM.SeverityNone, LM.ImpactNone, LM.MessageNameREQUEST, `Someone tried to read the TLS certificate's private key of the admin server. The attempt was inhibited.`)
|
||||
return
|
||||
}
|
||||
|
||||
if strings.ToLower(filename) == strings.ToLower(ConfigurationDB.Read(`PublicWebServerTLSCertificateName`)) {
|
||||
Log.LogFull(senderName, LM.CategorySYSTEM, LM.LevelSECURITY, LM.SeverityNone, LM.ImpactNone, LM.MessageNameREQUEST, `Someone tried to read the TLS certificate of the public server. The attempt was inhibited.`)
|
||||
return
|
||||
}
|
||||
|
||||
if strings.ToLower(filename) == strings.ToLower(ConfigurationDB.Read(`PublicWebServerTLSPrivateKey`)) {
|
||||
Log.LogFull(senderName, LM.CategorySYSTEM, LM.LevelSECURITY, LM.SeverityNone, LM.ImpactNone, LM.MessageNameREQUEST, `Someone tried to read the TLS certificate's private key of the public server. The attempt was inhibited.`)
|
||||
return
|
||||
}
|
||||
|
||||
result = FindAndReadFileINTERNAL(filename)
|
||||
return
|
||||
}
|
||||
|
||||
func FindAndReadFileINTERNAL(filename string) (result []byte) {
|
||||
|
||||
// Case: The system goes down.
|
||||
if Shutdown.IsDown() {
|
||||
return
|
||||
}
|
||||
|
||||
// Prepare the path:
|
||||
path := filename
|
||||
|
||||
|
||||
Reference in new issue
Block a user