diff options
author | FChannel <> | 2022-06-05 21:36:17 -0700 |
---|---|---|
committer | FChannel <> | 2022-06-19 12:53:29 -0700 |
commit | dac4b267cab31fb3a4ce301f1bcdf364fcb541a1 (patch) | |
tree | 22852a6457e08f3ea047d2c20900db73c26e2fda /activitypub | |
parent | 3ac22385f2cb2256db718e47f5ae3c6d13353b70 (diff) |
fix finger actor
Diffstat (limited to 'activitypub')
-rw-r--r-- | activitypub/actor.go | 10 | ||||
-rw-r--r-- | activitypub/util.go | 8 | ||||
-rw-r--r-- | activitypub/webfinger.go | 12 |
3 files changed, 21 insertions, 9 deletions
diff --git a/activitypub/actor.go b/activitypub/actor.go index c6283c8..e54088d 100644 --- a/activitypub/actor.go +++ b/activitypub/actor.go @@ -951,8 +951,7 @@ func (actor Actor) Verify(signature string, verify string) error { sig, _ := base64.StdEncoding.DecodeString(signature) if actor.PublicKey.PublicKeyPem == "" { - // TODO: this should be Finger but its not getting PublicKeyPem atm - _actor, err := GetActorFromDB(actor.Id) + _actor, err := FingerActor(actor.Id) if err != nil { return util.MakeError(err, "Verify") @@ -962,7 +961,12 @@ func (actor Actor) Verify(signature string, verify string) error { } block, _ := pem.Decode([]byte(actor.PublicKey.PublicKeyPem)) - pub, _ := x509.ParsePKIXPublicKey(block.Bytes) + + pub, err := x509.ParsePKIXPublicKey(block.Bytes) + + if err != nil { + return util.MakeError(err, "Verify") + } hashed := sha256.New() hashed.Write([]byte(verify)) diff --git a/activitypub/util.go b/activitypub/util.go index f53d8e5..274493f 100644 --- a/activitypub/util.go +++ b/activitypub/util.go @@ -282,6 +282,12 @@ func GetActorByNameFromDB(name string) (Actor, error) { return nActor, util.MakeError(err, "GetActorByNameFromDB") } + nActor.PublicKey, err = GetActorPemFromDB(publicKeyPem) + + if err != nil { + return nActor, util.MakeError(err, "GetActorFromDB") + } + if nActor.Id != "" && nActor.PublicKey.PublicKeyPem == "" { if err := CreatePublicKeyFromPrivate(&nActor, publicKeyPem); err != nil { return nActor, util.MakeError(err, "GetActorByNameFromDB") @@ -345,7 +351,7 @@ func GetActorFromDB(id string) (Actor, error) { err := config.DB.QueryRow(query, id).Scan(&nActor.Type, &nActor.Id, &nActor.Name, &nActor.PreferredUsername, &nActor.Inbox, &nActor.Outbox, &nActor.Following, &nActor.Followers, &nActor.Restricted, &nActor.Summary, &publicKeyPem) if err != nil { - return nActor, util.MakeError(err, "GetActorFromDB") + return nActor, nil } nActor.PublicKey, err = GetActorPemFromDB(publicKeyPem) diff --git a/activitypub/webfinger.go b/activitypub/webfinger.go index 276a791..8dce506 100644 --- a/activitypub/webfinger.go +++ b/activitypub/webfinger.go @@ -122,20 +122,22 @@ func FingerRequest(actor string, instance string) (*http.Response, error) { if len(finger.Links) > 0 { for _, e := range finger.Links { if e.Type == "application/activity+json" { - req, err := http.NewRequest("GET", e.Href, nil) + req, err = http.NewRequest("GET", e.Href, nil) if err != nil { return resp, util.MakeError(err, "FingerRequest") } - req.Header.Set("Accept", config.ActivityStreams) - resp, _ := util.RouteProxy(req) - - return resp, nil + break } } } + req.Header.Set("Accept", config.ActivityStreams) + if resp, err = util.RouteProxy(req); err != nil { + return resp, util.MakeError(err, "FingerRequest") + } + return resp, nil } |