1
0
mirror of https://github.com/rancher/rke.git synced 2025-04-27 19:25:44 +00:00

Update cert filename validation to *.pem

Users leveraging custom certs directories face errors when deploying
if the directory contains any files that do not end in .pem. This
change adds additional validation to ensure files are *.pem before
attempting further logic.

Signed-off-by: Alexander Hughes <Alexander.Hughes@pm.me>
This commit is contained in:
Alexander Hughes 2021-05-19 08:32:36 -04:00
parent 462a7ba01e
commit 9381a255bf

View File

@ -592,7 +592,7 @@ func ReadCertsAndKeysFromDir(certDir string) (map[string]CertificatePKI, error)
for _, file := range files {
logrus.Debugf("[certificates] reading file %s from directory [%s]", file.Name(), certDir)
if !strings.HasSuffix(file.Name(), "-key.pem") && !strings.HasSuffix(file.Name(), "-csr.pem") {
if strings.HasSuffix(file.Name(), ".pem") && !strings.HasSuffix(file.Name(), "-key.pem") && !strings.HasSuffix(file.Name(), "-csr.pem") {
// fetching cert
cert, err := getCertFromFile(certDir, file.Name())
if err != nil {