Skip to content

[stable32] hotfix: 6977 fix ca config loss#6981

Merged
vitormattos merged 8 commits intostable32from
backport/6980/stable32
Feb 20, 2026
Merged

[stable32] hotfix: 6977 fix ca config loss#6981
vitormattos merged 8 commits intostable32from
backport/6980/stable32

Conversation

@backportbot-libresign
Copy link

Backport of PR #6980

vitormattos and others added 8 commits February 20, 2026 21:24
The pki directory should not be deleted as it contains the new PKI
structure with CA certificates organized by instance and generation.

Related to #6977

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Fixed critical bugs in the migration that could cause CA certificate loss:

1. Replaced buggy empty(glob()) check with file_exists() for essential
   CA files (ca.pem and ca-key.pem) before copying
2. Only delete source directory after verifying both CA files exist
   in destination
3. Removed redundant addConfigPathToOpenSsl() from preSchemaChange
4. Removed unnecessary ca_id generation that incremented counter twice
5. Added warning logging when migration cannot verify files

The glob() function could return ['.', '..'] on some filesystems,
making empty() return false even for truly empty directories. This
caused the migration to skip copying files and then delete the source,
resulting in complete CA certificate loss.

Fixes #6977

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
…ate20260221000000)

Add repair migration to recover CA files for users already affected
by the Version13000Date20251031165700 bug.

Conservative approach:
- Only runs if config_path is empty or doesn't contain CA files
- Searches ONLY in old structure (openssl_config/cfssl_config)
- Never touches existing pki/ directories
- Moves files to correct location based on ca_id
- Updates metadata (ca_id, config_path, ca_generation_counter)
- Cleanup only removes empty old structure directories

This migration safely recovers CA certificates for affected users
without interfering with systems that migrated successfully.

Related to #6977

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
@github-project-automation github-project-automation bot moved this to 0. Needs triage in Roadmap Feb 20, 2026
@backportbot-libresign backportbot-libresign bot added this to the Next Patch (32) milestone Feb 20, 2026
@vitormattos vitormattos merged commit f9e21c6 into stable32 Feb 20, 2026
65 of 66 checks passed
@vitormattos vitormattos deleted the backport/6980/stable32 branch February 20, 2026 21:37
@github-project-automation github-project-automation bot moved this from 0. Needs triage to 4. to release in Roadmap Feb 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: 4. to release

Development

Successfully merging this pull request may close these issues.

1 participant