From 95b0e538188b517382b77602120049e8564002bb Mon Sep 17 00:00:00 2001 From: Aliaksei Shainiuk Date: Wed, 13 Mar 2024 20:37:53 +0100 Subject: [PATCH] Write private key in accordance with Asymmetric Key Packages RFC (#144) The key is marshaled using [MarshalPKCS8PrivateKey](https://pkg.go.dev/crypto/x509#MarshalPKCS8PrivateKey) which suggests the "PRIVATE KEY" PEM block type, and [Asymmetric Key Packages RFC](https://datatracker.ietf.org/doc/html/rfc5958) states: > When .p8 files are PEM encoded they use the .pem file extension. PEM encoding is ... Base64 encoding, see Section 4 of [RFC4648], of the DER-encoded PrivateKeyInfo sandwiched between: > -----BEGIN PRIVATE KEY----- > -----END PRIVATE KEY----- Signed-off-by: Aliaksei Shainiuk --- pkg/disk/x509.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/disk/x509.go b/pkg/disk/x509.go index 45fae8d9..013fb810 100644 --- a/pkg/disk/x509.go +++ b/pkg/disk/x509.go @@ -88,7 +88,7 @@ func writeCerts(file string, certs []*x509.Certificate) error { // formats as PEM, and writes it to file func writeKey(file string, data []byte) error { b := &pem.Block{ - Type: "EC PRIVATE KEY", + Type: "PRIVATE KEY", Bytes: data, }