Added default keys for testing

This commit is contained in:
2017-11-08 10:53:27 +01:00
parent a1ab50bd19
commit 1cd7e82d67
6 changed files with 128 additions and 9 deletions

33
security.go Normal file
View File

@ -0,0 +1,33 @@
package main
import (
"os"
"github.com/aerogo/aero"
)
func configureHTTPS(app *aero.Application) {
fullCertPath := "security/fullchain.pem"
fullKeyPath := "security/privkey.pem"
if _, err := os.Stat(fullCertPath); os.IsNotExist(err) {
defaultCertPath := "security/default/fullchain.pem"
err := os.Link(defaultCertPath, fullCertPath)
if err != nil {
panic(err)
}
}
if _, err := os.Stat(fullKeyPath); os.IsNotExist(err) {
defaultKeyPath := "security/default/privkey.pem"
err := os.Link(defaultKeyPath, fullKeyPath)
if err != nil {
panic(err)
}
}
// HTTPS
app.Security.Load(fullCertPath, fullKeyPath)
}