diff options
Diffstat (limited to '')
-rw-r--r-- | registry/registry.go | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/registry/registry.go b/registry/registry.go index c6c317c..dc5dff2 100644 --- a/registry/registry.go +++ b/registry/registry.go @@ -43,13 +43,21 @@ type Registry struct { func NewRegistry(cfg config.Config, persister *models.Persister, log *zap.SugaredLogger) (*Registry, error) { reg := Registry{cfg: cfg, persister: persister, log: log} reg.handlerMap = make(map[string]Handler) + var err error for _, v := range cfg.Handlers { reg.handlerMap[v.Name] = Handler{handlerCfg: v} - err := generateKeypairIfNeeded(v, persister) + err = generateKeypairIfNeeded(v, persister) if err != nil { return nil, err } } + prefs := []httpsig.Algorithm{} + digestAlgorithm := httpsig.DigestSha256 + headersToSign := []string{httpsig.RequestTarget, "host", "date", "digest"} + reg.signer, _, err = httpsig.NewSigner(prefs, digestAlgorithm, headersToSign, httpsig.Signature, 0) + if err != nil { + return nil, err + } return ®, nil } @@ -263,14 +271,7 @@ func (r *Registry) deliverAcceptToInbox(url, actorUrl, actorKeyUrl *url.URL, fol request.Header.Set("Host", url.Host) r.mu.Lock() - prefs := []httpsig.Algorithm{} - digestAlgorithm := httpsig.DigestSha256 - headersToSign := []string{httpsig.RequestTarget, "host", "date", "digest"} - signer, _, err := httpsig.NewSigner(prefs, digestAlgorithm, headersToSign, httpsig.Signature, 0) - if err != nil { - return err - } - err = signer.SignRequest(privKey, actorKeyUrl.String(), request, jsonData) + err = r.signer.SignRequest(privKey, actorKeyUrl.String(), request, jsonData) r.mu.Unlock() r.log.With( |