From 0e4b67bb5a28b403a61db5b191bc725a8191de4a Mon Sep 17 00:00:00 2001 From: Janis Danisevskis Date: Fri, 6 Sep 2024 10:38:06 -0700 Subject: [PATCH] Fix PEM header for generated public and private keys. Omiting the key type in the PEM header of the generated key leaves the key files malformed which confuses some parsers including openssl. --- pkg/provisioning/bootguard/keygen.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/provisioning/bootguard/keygen.go b/pkg/provisioning/bootguard/keygen.go index 9cce39e3..5ca58169 100644 --- a/pkg/provisioning/bootguard/keygen.go +++ b/pkg/provisioning/bootguard/keygen.go @@ -102,6 +102,7 @@ func writePrivKeyToFile(k crypto.PrivateKey, f *os.File, password string) error return fmt.Errorf("unable to marshal the private key: %w", err) } bpemBlock := &pem.Block{ + Type: "PRIVATE KEY", Bytes: b, } bpem := pem.EncodeToMemory(bpemBlock) @@ -128,6 +129,7 @@ func writePubKeyToFile(k crypto.PublicKey, f *os.File) error { return err } bpemBlock := &pem.Block{ + Type: "PUBLIC KEY", Bytes: b, } bpem := pem.EncodeToMemory(bpemBlock)