From b74190b22474986c20149b3a4a527a684f4ee3ce Mon Sep 17 00:00:00 2001 From: Julio Capote Date: Tue, 3 Jan 2023 21:10:38 -0500 Subject: render publickeypem in actor endpoints --- registry/registry.go | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'registry/registry.go') diff --git a/registry/registry.go b/registry/registry.go index e7f66fc..dc83328 100644 --- a/registry/registry.go +++ b/registry/registry.go @@ -2,7 +2,9 @@ package registry import ( "bytes" + "crypto/x509" "encoding/gob" + "encoding/pem" "net/http" "net/url" "strings" @@ -54,7 +56,26 @@ func (r *Registry) Actor(name string) (map[string]interface{}, error) { if handler == nil { return nil, nil } - return views.RenderActor(handler.handlerCfg.Name, r.cfg.Domain) + aso := models.NewKeypair(handler.handlerCfg) + result, err := r.persister.Find(aso) + if err != nil { + return nil, err + } + buf := bytes.NewBuffer(result) + dec := gob.NewDecoder(buf) + var keypair models.Keypair + err = dec.Decode(&keypair) + if err != nil { + return nil, err + } + privKey := &keypair.PrivateKey + pemdata := pem.EncodeToMemory( + &pem.Block{ + Type: "PUBLIC KEY", + Bytes: x509.MarshalPKCS1PublicKey(&privKey.PublicKey), + }, + ) + return views.RenderActor(handler.handlerCfg.Name, r.cfg.Domain, string(pemdata)) } func (r *Registry) OutboxCollection(name string) (map[string]interface{}, error) { -- cgit v1.2.3