From 66396ff79d72cfaa1aea89ad25a9648f08b2f0ea Mon Sep 17 00:00:00 2001 From: Julio Capote Date: Wed, 4 Jan 2023 10:06:02 -0500 Subject: replace newlines --- registry/registry.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'registry') diff --git a/registry/registry.go b/registry/registry.go index 83fe8e6..2833d57 100644 --- a/registry/registry.go +++ b/registry/registry.go @@ -3,7 +3,6 @@ package registry import ( "bytes" "context" - "crypto/rsa" "crypto/x509" "encoding/gob" "encoding/json" @@ -208,21 +207,18 @@ func (r *Registry) Inbox(name string, req *http.Request) error { pubKey := iter.Get() pemProp := pubKey.GetW3IDSecurityV1PublicKeyPem() pemStr := pemProp.Get() + pemStr = strings.ReplaceAll(pemStr, `\n`, "") logger.With("keyId", keyId).With("pem", pemStr).Debugf("extracted pem") pemObj, _ := pem.Decode([]byte(pemStr)) if pemObj == nil { return fmt.Errorf("no PEM block found") } - decodedKey, err := x509.ParsePKIXPublicKey(pemObj.Bytes) + decodedKey, err := x509.ParsePKCS1PublicKey(pemObj.Bytes) if err != nil { return err } - rsaPub, ok := decodedKey.(*rsa.PublicKey) - if !ok { - return fmt.Errorf("not an RSA public key") - } algo := httpsig.RSA_SHA256 - return verifier.Verify(rsaPub, algo) + return verifier.Verify(decodedKey, algo) } func (r *Registry) ActivityOrNote(activityOrNote, name, id string) (map[string]interface{}, error) { -- cgit v1.2.3