Skip to content
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
18 changes: 17 additions & 1 deletion pkg/initdata/initdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"bytes"
"compress/gzip"
"encoding/base64"
"encoding/pem"
"fmt"
"io"
"os"
Expand Down Expand Up @@ -224,7 +225,22 @@ func generateCDHToml(cfg *config.CocoConfig, caCert string, imagePullSecrets []I
}

if caCert != "" {
imageConfig["extra_root_certificates"] = []string{caCert}
// 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 {
Comment on lines +228 to +233
var block *pem.Block
block, rest = pem.Decode(rest)
if block == nil {
break
}
entries = append(entries, string(pem.EncodeToMemory(block)))
}
Comment thread
bpradipt marked this conversation as resolved.
if len(entries) > 0 {
imageConfig["extra_root_certificates"] = entries
}
}

if len(imageConfig) > 0 {
Expand Down
Loading