Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix certreloader update logic #111

Merged
merged 8 commits into from
Mar 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions pkg/certificate/service.go
Original file line number Diff line number Diff line change
@@ -192,9 +192,11 @@ func New(ctx context.Context, idCfg *config.IdentityConfig) (daemon.Daemon, erro
if err != nil {
log.Errorf("Failed to retrieve x509 certificate from identity provider: %s", err.Error())
}
err = idCfg.Reloader.UpdateCertificate([]byte(identity.X509CertificatePEM), keyPEM)
if err != nil {
log.Errorf("Failed to reload x509 certificate from identity provider: %s", err.Error())
if identity != nil && len(keyPEM) != 0 {
errUpdate := idCfg.Reloader.UpdateCertificate([]byte(identity.X509CertificatePEM), keyPEM)
if errUpdate != nil {
log.Errorf("Failed to update x509 certificate into certificate reloader: %s", errUpdate.Error())
}
}
} else if idCfg.KeyFile != "" && idCfg.CertFile != "" {
log.Debug("Attempting to load x509 certificate from cert reloader...")
@@ -232,10 +234,11 @@ func New(ctx context.Context, idCfg *config.IdentityConfig) (daemon.Daemon, erro
identity = k8sSecretBackupIdentity
keyPEM = k8sSecretBackupKeyPEM
log.Infof("Successfully loaded x509 certificate from kubernetes secret")

err = idCfg.Reloader.UpdateCertificate([]byte(identity.X509CertificatePEM), keyPEM)
if err != nil {
log.Errorf("Failed to reload x509 certificate from identity provider: %s", err.Error())
if identity != nil && len(keyPEM) != 0 {
errUpdate := idCfg.Reloader.UpdateCertificate([]byte(identity.X509CertificatePEM), keyPEM)
if errUpdate != nil {
log.Errorf("Failed to update x509 certificate into certificate reloader: %s", errUpdate.Error())
}
}
}
} else {
@@ -255,9 +258,12 @@ func New(ctx context.Context, idCfg *config.IdentityConfig) (daemon.Daemon, erro
} else {
identity = forceInitIdentity
keyPEM = forceInitKeyPEM
err = idCfg.Reloader.UpdateCertificate([]byte(identity.X509CertificatePEM), keyPEM)
if err != nil {
log.Errorf("Failed to reload x509 certificate from identity provider: %s", err.Error())

if identity != nil && len(keyPEM) != 0 {
errUpdate := idCfg.Reloader.UpdateCertificate([]byte(identity.X509CertificatePEM), keyPEM)
if errUpdate != nil {
log.Errorf("Failed to update x509 certificate into certificate reloader: %s", errUpdate.Error())
}
}
}
}