From 4c81fd7d169e581d14c7e7705b0e4f2d7086b298 Mon Sep 17 00:00:00 2001 From: Ke Wang Date: Tue, 1 Nov 2022 22:19:38 +0800 Subject: [PATCH] feat: fix generating wrong x.509 private key file header (#1253) According to the [official x509 documentation](https://pkg.go.dev/crypto/x509#MarshalPKCS1PrivateKey), the private key generated using `x509.MarshalPKCS1PrivateKey` starts with `-----BEGIN RSA PRIVATE KEY-----` instead of `-----BEGIN PRIVATE KEY-----`. Otherwise, it will not be parsed by most tools (like OpenSSL, [jwt.io](https://jwt.io/), etc.) because it does not conform to the specification. --- object/token_jwt_key.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/object/token_jwt_key.go b/object/token_jwt_key.go index 4cd33eb7..7091c14f 100644 --- a/object/token_jwt_key.go +++ b/object/token_jwt_key.go @@ -37,7 +37,7 @@ func generateRsaKeys(bitSize int, expireInYears int, commonName string, organiza // Encode private key to PKCS#1 ASN.1 PEM. privateKeyPem := pem.EncodeToMemory( &pem.Block{ - Type: "PRIVATE KEY", + Type: "RSA PRIVATE KEY", Bytes: x509.MarshalPKCS1PrivateKey(key), }, )