diff options
author | Anthony Wang | 2022-03-29 16:38:27 -0500 |
---|---|---|
committer | Anthony Wang | 2022-03-29 16:38:27 -0500 |
commit | 65016b26645d6fdcf0e7c47fc1214bd8b8e723a2 (patch) | |
tree | f677251801082570a9fd06de6ac97870f10171ae | |
parent | d1a53f7d6ad7651ed05732aed1c76a7ebad85d6c (diff) |
Check if digest algo is supported in setting module
-rw-r--r-- | modules/activitypub/client.go | 7 | ||||
-rw-r--r-- | modules/setting/federation.go | 9 |
2 files changed, 10 insertions, 6 deletions
diff --git a/modules/activitypub/client.go b/modules/activitypub/client.go index 254cec0f8..5c9ea2dd3 100644 --- a/modules/activitypub/client.go +++ b/modules/activitypub/client.go @@ -61,9 +61,6 @@ func NewClient(user *user_model.User, pubID string) (c *Client, err error) { return } else if err = containsRequiredHTTPHeaders(http.MethodPost, setting.Federation.PostHeaders); err != nil { return - } else if !httpsig.IsSupportedDigestAlgorithm(setting.Federation.DigestAlgorithm) { - err = fmt.Errorf("unsupported digest algorithm: %s", setting.Federation.DigestAlgorithm) - return } algos := make([]httpsig.Algorithm, len(setting.Federation.Algorithms)) for i, algo := range setting.Federation.Algorithms { @@ -85,8 +82,8 @@ func NewClient(user *user_model.User, pubID string) (c *Client, err error) { } c = &Client{ - clock: clock, - client: &http.Client{ + clock: clock, + client: &http.Client{ Transport: &http.Transport{ Proxy: proxy.Proxy(), }, diff --git a/modules/setting/federation.go b/modules/setting/federation.go index 12330c6cf..8aa481cd9 100644 --- a/modules/setting/federation.go +++ b/modules/setting/federation.go @@ -4,7 +4,11 @@ package setting -import "code.gitea.io/gitea/modules/log" +import ( + "code.gitea.io/gitea/modules/log" + + "github.com/go-fed/httpsig" +) // Federation settings var ( @@ -26,5 +30,8 @@ var ( func newFederationService() { if err := Cfg.Section("federation").MapTo(&Federation); err != nil { log.Fatal("Failed to map Federation settings: %v", err) + } else if !httpsig.IsSupportedDigestAlgorithm(Federation.DigestAlgorithm) { + log.Fatal("unsupported digest algorithm: %s", Federation.DigestAlgorithm) + return } } |