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

Do not rotate JWT keys if X509 preparation failed during initialization #5064

Merged
merged 3 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 4 additions & 0 deletions pkg/server/ca/manager/journal.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,10 @@ func (j *Journal) saveInDatastore(ctx context.Context, entriesBytes []byte) (caJ
// Check if we already identified what's the CA journal for this server in
// the datastore. If not, log that we are creating a new CA journal entry.
if j.caJournalID == 0 {
if j.activeX509AuthorityID == "" {
j.config.log.Debug("There is no active X509 authority yet. Can't save CA journal in the datastore")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
j.config.log.Debug("There is no active X509 authority yet. Can't save CA journal in the datastore")
j.config.log.Debug("There is no active X.509 authority yet. Can't save CA journal in the datastore")

nit

return 0, nil
}
j.config.log.Info("Creating a new CA journal entry")
}

Expand Down
6 changes: 6 additions & 0 deletions pkg/server/ca/rotator/rotator.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ func (r *Rotator) rotate(ctx context.Context) error {
if x509CAErr != nil {
atomic.AddUint64(&r.failedRotationNum, 1)
r.c.Log.WithError(x509CAErr).Error("Unable to rotate X509 CA")
if r.c.Manager.GetCurrentX509CASlot().IsEmpty() {
// Preparation of the X509 CA failed, and there is no active X509
// authority. We will be unable to store the JWT authority, so we
rturner3 marked this conversation as resolved.
Show resolved Hide resolved
// don't try to rotate the JWT key in this case.
return x509CAErr
}
}

jwtKeyErr := r.rotateJWTKey(ctx)
Expand Down
Loading