fixed issues with CA now generates its own new cert
All checks were successful
release / build-and-upload (push) Successful in 16m53s
All checks were successful
release / build-and-upload (push) Successful in 16m53s
This commit is contained in:
parent
a930a697fa
commit
c1948a1439
11 changed files with 458 additions and 34 deletions
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue