Skip to content

fix(initdata): split multi-cert PEM into one extra_root_certificates entry each#48

Merged
bpradipt merged 1 commit into
confidential-devhub:mainfrom
bpradipt:multicert
Jun 3, 2026
Merged

fix(initdata): split multi-cert PEM into one extra_root_certificates entry each#48
bpradipt merged 1 commit into
confidential-devhub:mainfrom
bpradipt:multicert

Conversation

@bpradipt

@bpradipt bpradipt commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

generateCDHToml was putting the entire certPEM string (which may contain multiple PEM-encoded certificates from --cacert or --capath

) as a single extra_root_certificates array element.

The validate command already enforced that each element must contain exactly one certificate. The create path now matches: it decodes the PEM block by block and appends each certificate as its own array entry.

Before: extra_root_certificates = ["cert1\ncert2"] (combined, rejected by validate)
After: extra_root_certificates = ["cert1", "cert2"] (one per element, accepted)

…entry each

generateCDHToml was putting the entire certPEM string (which may
contain multiple PEM-encoded certificates from --cacert <multi-cert>
or --capath <dir>) as a single extra_root_certificates array element.

The validate command already enforced that each element must contain
exactly one certificate. The create path now matches: it decodes the
PEM block by block and appends each certificate as its own array entry.

Before: extra_root_certificates = ["cert1\ncert2"]  (combined, rejected by validate)
After:  extra_root_certificates = ["cert1", "cert2"]  (one per element, accepted)
Signed-off-by: Pradipta Banerjee <pradipta.banerjee@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR updates generateCDHToml to split a potentially multi-certificate PEM bundle into multiple cdh.toml image.extra_root_certificates entries (one certificate per array element), aligning initdata generation with what initdata validate enforces.

Changes:

  • Decode the caCert PEM block-by-block and append each block as a separate extra_root_certificates entry instead of storing the entire PEM bundle as a single element.
  • Add encoding/pem import to support PEM block decoding/encoding during cdh.toml generation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/initdata/initdata.go
Comment thread pkg/initdata/initdata.go
Comment on lines +228 to +233
// Split the PEM into one entry per certificate so that each element
// in extra_root_certificates contains exactly one certificate.
// This matches what initdata validate enforces.
var entries []string
rest := []byte(caCert)
for {
@bpradipt bpradipt merged commit a612664 into confidential-devhub:main Jun 3, 2026
3 checks passed
@bpradipt bpradipt deleted the multicert branch June 3, 2026 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants