fixed issues with CA now generates its own new cert
All checks were successful
release / build-and-upload (push) Successful in 16m53s

This commit is contained in:
404errordeveloper 2026-10-08 20:16:08 +02:00
parent a930a697fa
commit c1948a1439
11 changed files with 458 additions and 34 deletions

View file

@ -1240,15 +1240,19 @@ func loadOrCreateCA(certPath, keyPath string) (*tls.Certificate, error) {
if _, err := os.Stat(keyPath); err == nil {
cert, err := tls.LoadX509KeyPair(certPath, keyPath)
if err != nil {
return nil, err
}
if len(cert.Certificate) > 0 {
leaf, err := x509.ParseCertificate(cert.Certificate[0])
if err == nil {
cert.Leaf = leaf
// Stale key left on device after install-ca replaced only the cert.
log.Printf("CA pair unusable (%v) — removing %s and %s so a matching pair can be pushed/recreated", err, certPath, keyPath)
_ = os.Remove(certPath)
_ = os.Remove(keyPath)
} else {
if len(cert.Certificate) > 0 {
leaf, err := x509.ParseCertificate(cert.Certificate[0])
if err == nil {
cert.Leaf = leaf
}
}
return &cert, nil
}
return &cert, nil
}
}