From 8693fb6a251429374a2898a82d82f13b94896515 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. Signed-off-by: Janis Danisevskis --- 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)