feat: add certmagic for automatic TLS certificate management
All checks were successful
Docker Build and Push / build-and-push (push) Successful in 3m28s

This commit is contained in:
2025-12-26 23:44:50 +07:00
parent 76d1202b8e
commit c69cd68820
10 changed files with 403 additions and 108 deletions

View File

@@ -13,13 +13,14 @@ import (
)
func NewHTTPSServer() error {
cert, err := tls.LoadX509KeyPair(utils.Getenv("CERT_LOC", "certs/cert.pem"), utils.Getenv("KEY_LOC", "certs/privkey.pem"))
domain := utils.Getenv("DOMAIN", "localhost")
tlsConfig, err := NewTLSConfig(domain)
if err != nil {
return err
return fmt.Errorf("failed to initialize TLS config: %w", err)
}
config := &tls.Config{Certificates: []tls.Certificate{cert}}
ln, err := tls.Listen("tcp", ":443", config)
ln, err := tls.Listen("tcp", ":443", tlsConfig)
if err != nil {
return err
}