Skip to content

Commit

Permalink
Actually fix agent certificate rotation
Browse files Browse the repository at this point in the history
Signed-off-by: Brad Davidson <[email protected]>
  • Loading branch information
brandond committed Apr 10, 2024
1 parent 08f1022 commit 4cc73b1
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions pkg/cli/cert/cert.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"os"
"path/filepath"
"strconv"
"strings"
"time"

Expand Down Expand Up @@ -191,14 +190,20 @@ func rotate(app *cli.Context, cfg *cmds.Server) error {
}

func backupCertificates(serverDataDir, agentDataDir string, fileMap map[string][]string) (string, error) {
backupDirName := fmt.Sprintf("tls-%d", time.Now().Unix())
serverTLSDir := filepath.Join(serverDataDir, "tls")
tlsBackupDir := filepath.Join(serverDataDir, "tls-"+strconv.Itoa(int(time.Now().Unix())))
tlsBackupDir := filepath.Join(agentDataDir, backupDirName)

// backup the server TLS dir if it exists
if _, err := os.Stat(serverTLSDir); err != nil {
return "", err
}
if err := copy.Copy(serverTLSDir, tlsBackupDir); err != nil {
return "", err
if !os.IsNotExist(err) {
return "", err
}
} else {
tlsBackupDir = filepath.Join(serverDataDir, backupDirName)
if err := copy.Copy(serverTLSDir, tlsBackupDir); err != nil {
return "", err
}
}

for _, files := range fileMap {
Expand Down

0 comments on commit 4cc73b1

Please sign in to comment.