aboutsummaryrefslogtreecommitdiff
path: root/registry
diff options
context:
space:
mode:
authorJulio Capote <jcapote@gmail.com>2023-01-06 15:21:48 +0000
committerJulio Capote <jcapote@gmail.com>2023-01-06 15:21:48 +0000
commit33573ed878b16bd1200659e2a2f401247aff43a4 (patch)
treeda41b7571e2289e52567a50f173b637f28161004 /registry
parentcfacb61e22458de46789dab9b40b18d4db1d00ec (diff)
downloadcommunique-33573ed878b16bd1200659e2a2f401247aff43a4.tar.gz
verify before sending
Diffstat (limited to 'registry')
-rw-r--r--registry/registry.go14
1 files changed, 13 insertions, 1 deletions
diff --git a/registry/registry.go b/registry/registry.go
index d2c0794..25ea338 100644
--- a/registry/registry.go
+++ b/registry/registry.go
@@ -290,10 +290,22 @@ func (r *Registry) deliverAcceptToInbox(url, actorUrl, actorKeyUrl *url.URL, fol
digestBytes := sha256.Sum256([]byte(signedString))
+ fmt.Println()
+ fmt.Println()
+ fmt.Println("'" + signedString + "'")
+ fmt.Println()
+ fmt.Println()
+
r.mu.Lock()
signature, err := rsa.SignPKCS1v15(rand.Reader, privKey, crypto.SHA256, digestBytes[:])
if err != nil {
- r.log.Error(err)
+ return err
+ }
+
+ // verify our own signature to ensure sanity
+ err = rsa.VerifyPKCS1v15(&privKey.PublicKey, crypto.SHA256, digestBytes[:], signature)
+ if err != nil {
+ return err
}
r.mu.Unlock()