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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user