1
0
mirror of https://github.com/amir20/dozzle.git synced 2025-12-25 06:49:23 +01:00

feat: reads certs locally if available (#3196)

This commit is contained in:
Amir Raminfar
2024-08-13 11:48:56 -07:00
committed by GitHub
parent 9467e3d7d5
commit 7f735d26db
3 changed files with 33 additions and 2 deletions

View File

@@ -3,9 +3,22 @@ package cli
import (
"crypto/tls"
"embed"
"os"
log "github.com/sirupsen/logrus"
)
func ReadCertificates(certs embed.FS) (tls.Certificate, error) {
if pair, err := tls.LoadX509KeyPair("dozzle_cert.pem", "dozzle_key.pem"); err == nil {
log.Infof("Found dozzle certificate and key at ./dozzle_cert.pem and ./dozzle_key.pem")
return pair, nil
} else {
if !os.IsNotExist(err) {
log.Errorf("Failed to load dozzle certificate and key: %v", err)
log.Warnf("Falling back to shared certificate and key")
}
}
cert, err := certs.ReadFile("shared_cert.pem")
if err != nil {
return tls.Certificate{}, err