mirror of https://github.com/jlelse/GoBlog
Small activitypub changes
parent
58586fb9a7
commit
04f5cdc122
|
@ -68,10 +68,13 @@ func initActivityPub() error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
prefs := []httpsig.Algorithm{httpsig.RSA_SHA256}
|
||||
digestAlgorithm := httpsig.DigestSha256
|
||||
headersToSign := []string{httpsig.RequestTarget, "date", "host", "digest"}
|
||||
apPostSigner, _, err = httpsig.NewSigner(prefs, digestAlgorithm, headersToSign, httpsig.Signature, 0)
|
||||
apPostSigner, _, err = httpsig.NewSigner(
|
||||
[]httpsig.Algorithm{httpsig.RSA_SHA256},
|
||||
httpsig.DigestSha256,
|
||||
[]string{httpsig.RequestTarget, "date", "host", "digest"},
|
||||
httpsig.Signature,
|
||||
0,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -96,14 +96,13 @@ func apQueueSendSigned(blogIri, to string, activity interface{}) error {
|
|||
}
|
||||
|
||||
func apSendSigned(blogIri, to string, activity []byte) error {
|
||||
// Copy activity to sign it
|
||||
activityCopy := make([]byte, len(activity))
|
||||
copy(activityCopy, activity)
|
||||
// Create request context with timeout
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
|
||||
defer cancel()
|
||||
// Create request
|
||||
r, err := http.NewRequestWithContext(ctx, http.MethodPost, to, bytes.NewBuffer(activity))
|
||||
var requestBuffer bytes.Buffer
|
||||
requestBuffer.Write(activity)
|
||||
r, err := http.NewRequestWithContext(ctx, http.MethodPost, to, &requestBuffer)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -119,7 +118,7 @@ func apSendSigned(blogIri, to string, activity []byte) error {
|
|||
r.Header.Set("Host", iri.Host)
|
||||
// Sign request
|
||||
apPostSignMutex.Lock()
|
||||
err = apPostSigner.SignRequest(apPrivateKey, blogIri+"#main-key", r, activityCopy)
|
||||
err = apPostSigner.SignRequest(apPrivateKey, blogIri+"#main-key", r, activity)
|
||||
apPostSignMutex.Unlock()
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
Loading…
Reference in New Issue