Create bogus certificate if none passed

This commit is contained in:
DataHoarder 2022-01-16 15:26:13 +01:00
parent 249f03fdd0
commit 845cf15314
2 changed files with 12 additions and 5 deletions

View file

@ -1,6 +1,6 @@
DATA_MOUNT_PATH=/mnt/storage
CERTIFICATE_PATH=/example/server.crt
KEYPAIR_PATH=/example/server.key
CERTIFICATE_PATH=
KEYPAIR_PATH=
LISTEN_PORT=7777
TRUSTED_KEYS=

View file

@ -605,9 +605,16 @@ func main() {
if err != nil {
log.Fatal(err)
}
serverCertificate, err := tls.LoadX509KeyPair(*certificatePath, *keypairPath)
if err != nil {
log.Fatal(err)
var serverCertificate tls.Certificate
if *certificatePath != "" && *keypairPath != "" {
serverCertificate, err = tls.LoadX509KeyPair(*certificatePath, *keypairPath)
if err != nil {
log.Fatal(err)
}
} else {
serverCertificate = bogusCertificate
}
server := &http.Server{