diff options
author | Julio Capote <jcapote@gmail.com> | 2023-01-04 02:10:38 +0000 |
---|---|---|
committer | Julio Capote <jcapote@gmail.com> | 2023-01-04 02:10:38 +0000 |
commit | b74190b22474986c20149b3a4a527a684f4ee3ce (patch) | |
tree | c61550b0990b946a5db41c0177f705e6ecc87744 /registry | |
parent | 8f83ac669faa22a684176f8ae796f088f4cde8b6 (diff) | |
download | communique-b74190b22474986c20149b3a4a527a684f4ee3ce.tar.gz |
render publickeypem in actor endpoints
Diffstat (limited to '')
-rw-r--r-- | registry/registry.go | 23 |
1 files changed, 22 insertions, 1 deletions
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) { |