Skip to content

Commit

Permalink
Merge pull request #15 from writeas/fix-key-decoding
Browse files Browse the repository at this point in the history
Support decoding PKCS#8 keys
  • Loading branch information
thebaer authored Nov 11, 2022
2 parents ab8ed5d + 73b029d commit b5516d2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions activitypub/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b5516d2

Please sign in to comment.