1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2026-10-28 15:02:28 +00:00

chasquid: support key.pem private filename

Lego, the ACME client used by the NixOS ACME module, names the private
keys `key.pem`.
Auto-detect that filename so Chasquid just works with Lego & NixOS ACME.

https://go-acme.github.io/lego/
https://wiki.nixos.org/wiki/ACME
This commit is contained in:
ThinkChaos
2025-08-13 22:12:04 -04:00
committed by Alberto Bertogli
parent f69fdc1b1a
commit a09963d91f
+26 -3
View File
@@ -269,18 +269,41 @@ func loadCert(name, dir string, s *smtpsrv.Server) {
log.Infof(" skipping: %v", err)
return
}
keyPath := filepath.Join(dir, "privkey.pem")
if _, err := os.Stat(keyPath); err != nil {
keyPath, err := findCertKey(dir)
if err != nil {
log.Infof(" skipping: %v", err)
return
}
err := s.AddCerts(certPath, keyPath)
err = s.AddCerts(certPath, keyPath)
if err != nil {
log.Fatalf(" %v", err)
}
}
func findCertKey(dir string) (string, error) {
keyFiles := []string{
// Lego (NixOS ACME module).
"key.pem",
// Letsencrypt Certbot.
"privkey.pem",
}
var err error
for _, name := range keyFiles {
keyPath := filepath.Join(dir, name)
_, err = os.Stat(keyPath)
if err == nil {
return keyPath, nil
}
}
return "", err
}
// Helper to load a single domain configuration into the server.
func loadDomain(name, dir string, s *smtpsrv.Server) {
s.AddDomain(name)