Update activityserve to use current httpsig
parent
1120dff00d
commit
4a526aae09
16
actor.go
16
actor.go
|
@ -18,9 +18,7 @@ import (
|
||||||
"crypto"
|
"crypto"
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"crypto/rsa"
|
"crypto/rsa"
|
||||||
"crypto/sha256"
|
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"encoding/base64"
|
|
||||||
"encoding/pem"
|
"encoding/pem"
|
||||||
|
|
||||||
"github.com/dchest/uniuri"
|
"github.com/dchest/uniuri"
|
||||||
|
@ -456,7 +454,7 @@ func (a *Actor) signedHTTPPost(content map[string]interface{}, to string) (err e
|
||||||
log.Info(err)
|
log.Info(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
postSigner, _, _ := httpsig.NewSigner([]httpsig.Algorithm{httpsig.RSA_SHA256}, []string{"(request-target)", "date", "host", "digest"}, httpsig.Signature)
|
postSigner, _, _ := httpsig.NewSigner([]httpsig.Algorithm{httpsig.RSA_SHA256}, "SHA-256", []string{"(request-target)", "date", "host", "digest"}, httpsig.Signature)
|
||||||
|
|
||||||
byteCopy := make([]byte, len(b))
|
byteCopy := make([]byte, len(b))
|
||||||
copy(byteCopy, b)
|
copy(byteCopy, b)
|
||||||
|
@ -480,11 +478,7 @@ func (a *Actor) signedHTTPPost(content map[string]interface{}, to string) (err e
|
||||||
req.Header.Add("Host", iri.Host)
|
req.Header.Add("Host", iri.Host)
|
||||||
req.Header.Add("Accept", "application/activity+json; charset=utf-8")
|
req.Header.Add("Accept", "application/activity+json; charset=utf-8")
|
||||||
req.Header.Add("Content-Type", "application/activity+json; charset=utf-8")
|
req.Header.Add("Content-Type", "application/activity+json; charset=utf-8")
|
||||||
sum := sha256.Sum256(b)
|
err = postSigner.SignRequest(a.privateKey, a.publicKeyID, req, byteCopy)
|
||||||
req.Header.Add("Digest",
|
|
||||||
fmt.Sprintf("SHA-256=%s",
|
|
||||||
base64.StdEncoding.EncodeToString(sum[:])))
|
|
||||||
err = postSigner.SignRequest(a.privateKey, a.publicKeyID, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Info(err)
|
log.Info(err)
|
||||||
return
|
return
|
||||||
|
@ -527,8 +521,8 @@ func (a *Actor) signedHTTPGet(address string) (string, error) {
|
||||||
req.Header.Add("Accept", "application/activity+json; profile=\"https://www.w3.org/ns/activitystreams\"")
|
req.Header.Add("Accept", "application/activity+json; profile=\"https://www.w3.org/ns/activitystreams\"")
|
||||||
|
|
||||||
// set up the http signer
|
// set up the http signer
|
||||||
signer, _, _ := httpsig.NewSigner([]httpsig.Algorithm{httpsig.RSA_SHA256}, []string{"(request-target)", "date", "host", "digest"}, httpsig.Signature)
|
signer, _, _ := httpsig.NewSigner([]httpsig.Algorithm{httpsig.RSA_SHA256}, "SHA-256", []string{"(request-target)", "date", "host", "digest"}, httpsig.Signature)
|
||||||
err = signer.SignRequest(a.privateKey, a.publicKeyID, req)
|
err = signer.SignRequest(a.privateKey, a.publicKeyID, req, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Can't sign the request")
|
log.Error("Can't sign the request")
|
||||||
return "", err
|
return "", err
|
||||||
|
@ -679,7 +673,7 @@ func (a *Actor) Unfollow(user string) {
|
||||||
undo := make(map[string]interface{})
|
undo := make(map[string]interface{})
|
||||||
undo["@context"] = context()
|
undo["@context"] = context()
|
||||||
undo["actor"] = a.iri
|
undo["actor"] = a.iri
|
||||||
undo["id"] = baseURL + "/item/" + hash + "/undo"
|
undo["id"] = baseURL + "item/" + hash + "/undo"
|
||||||
undo["type"] = "Undo"
|
undo["type"] = "Undo"
|
||||||
|
|
||||||
follow := make(map[string]interface{})
|
follow := make(map[string]interface{})
|
||||||
|
|
Loading…
Reference in New Issue