fix: certificate generation and Vault recovery bugs#970
Open
sinchubhat wants to merge 3 commits into
Open
Conversation
- Return parsed certificate instead of template struct (empty .Raw field) in GenerateRootCertificate and IssueWebServerCertificate - Validate certificates loaded from Vault and delete if malformed - Persist web server certificate files to disk when loading from Vault (CIRA server reads cert files from disk) - Persist web server certificate files to disk after generation Addresses device-management-toolkit/deployment#573
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #970 +/- ##
==========================================
+ Coverage 40.78% 41.48% +0.70%
==========================================
Files 134 134
Lines 12297 12322 +25
==========================================
+ Hits 5015 5112 +97
+ Misses 6759 6659 -100
- Partials 523 551 +28 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
6f02c34 to
a1ccb6e
Compare
There was a problem hiding this comment.
Pull request overview
This PR fixes certificate handling so generated certificates return parsed DER-backed structures and web server certificates can be restored from Vault for CIRA disk-based usage.
Changes:
- Returns parsed certificates from root and web server certificate generation.
- Adds Vault certificate load validation and malformed-cert cleanup path.
- Adds tests for parsed certificate
.Rawcontent and web server cert persistence.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
internal/certificates/generate.go |
Updates certificate store field constants, Vault load validation, parsed certificate returns, and disk persistence for web server certs. |
internal/certificates/generate_test.go |
Adds tests covering Vault loading, parsed certificate returns, and disk persistence behavior. |
- Delete malformed PEM entries from Vault on decode failures - Propagate saveCertAndKeyToFiles errors instead of logging warnings - Add HEADLESS env var check to skip browser launch in containers - Fix inverted GIN_MODE condition in handleDebugMode Addresses device-management-toolkit/deployment#573
sudhir-intc
approved these changes
May 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses device-management-toolkit/deployment#573
Output:
After restart:
"Root certificate loaded from Vault" — loaded instead of regenerated
"Web server certificate loaded from Vault" — loaded instead of regenerated
No panic, no crash, CIRA server running