From 73b029dffaf3e6396da06fd104adc5f53a09e4f7 Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Fri, 11 Nov 2022 01:56:53 -0500 Subject: [PATCH] Support decoding PKCS#8 keys These are generated by OpenSSL v3. Previously, key decoding would fail, breaking federation. This fixes #14 --- activitypub/keys.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/activitypub/keys.go b/activitypub/keys.go index 9540668..51ae2ec 100644 --- a/activitypub/keys.go +++ b/activitypub/keys.go @@ -69,8 +69,8 @@ func parsePublicKey(der []byte) (crypto.PublicKey, error) { // them in that order. func DecodePrivateKey(k []byte) (crypto.PrivateKey, error) { block, _ := pem.Decode(k) - if block == nil || block.Type != "RSA PRIVATE KEY" { - return nil, fmt.Errorf("failed to decode PEM block containing private key") + if block == nil || (block.Type != "RSA PRIVATE KEY" && block.Type != "PRIVATE KEY") { + return nil, fmt.Errorf("failed to decode PEM block containing private key, type %s", block.Type) } return parsePrivateKey(block.Bytes)