mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-26 08:13:09 -06:00
Fix disabling TLS validation
This commit is contained in:
parent
e5d034f34d
commit
4a1c772bdc
|
|
@ -78,7 +78,7 @@ func createFederationClient(
|
||||||
)
|
)
|
||||||
return gomatrixserverlib.NewFederationClient(
|
return gomatrixserverlib.NewFederationClient(
|
||||||
base.Base.Cfg.Global.ServerName, base.Base.Cfg.Global.KeyID,
|
base.Base.Cfg.Global.ServerName, base.Base.Cfg.Global.KeyID,
|
||||||
base.Base.Cfg.Global.PrivateKey, true,
|
base.Base.Cfg.Global.PrivateKey,
|
||||||
gomatrixserverlib.WithTransport(tr),
|
gomatrixserverlib.WithTransport(tr),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ func (n *Node) CreateFederationClient(
|
||||||
)
|
)
|
||||||
return gomatrixserverlib.NewFederationClient(
|
return gomatrixserverlib.NewFederationClient(
|
||||||
base.Cfg.Global.ServerName, base.Cfg.Global.KeyID,
|
base.Cfg.Global.ServerName, base.Cfg.Global.KeyID,
|
||||||
base.Cfg.Global.PrivateKey, true,
|
base.Cfg.Global.PrivateKey,
|
||||||
gomatrixserverlib.WithTransport(tr),
|
gomatrixserverlib.WithTransport(tr),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -139,7 +139,7 @@ func createFederationClient(cfg *config.Dendrite, node *go_http_js_libp2p.P2pLoc
|
||||||
tr := go_http_js_libp2p.NewP2pTransport(node)
|
tr := go_http_js_libp2p.NewP2pTransport(node)
|
||||||
|
|
||||||
fed := gomatrixserverlib.NewFederationClient(
|
fed := gomatrixserverlib.NewFederationClient(
|
||||||
cfg.Global.ServerName, cfg.Global.KeyID, cfg.Global.PrivateKey, true,
|
cfg.Global.ServerName, cfg.Global.KeyID, cfg.Global.PrivateKey,
|
||||||
gomatrixserverlib.WithTransport(tr),
|
gomatrixserverlib.WithTransport(tr),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,6 @@ func main() {
|
||||||
gomatrixserverlib.ServerName(*requestFrom),
|
gomatrixserverlib.ServerName(*requestFrom),
|
||||||
gomatrixserverlib.KeyID(keyBlock.Headers["Key-ID"]),
|
gomatrixserverlib.KeyID(keyBlock.Headers["Key-ID"]),
|
||||||
privateKey,
|
privateKey,
|
||||||
false,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
u, err := url.Parse(flag.Arg(0))
|
u, err := url.Parse(flag.Arg(0))
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ func TestRoomsV3URLEscapeDoNot404(t *testing.T) {
|
||||||
serverName := gomatrixserverlib.ServerName(strings.TrimPrefix(baseURL, "https://"))
|
serverName := gomatrixserverlib.ServerName(strings.TrimPrefix(baseURL, "https://"))
|
||||||
|
|
||||||
fedCli := gomatrixserverlib.NewFederationClient(
|
fedCli := gomatrixserverlib.NewFederationClient(
|
||||||
serverName, cfg.Global.KeyID, cfg.Global.PrivateKey, true,
|
serverName, cfg.Global.KeyID, cfg.Global.PrivateKey,
|
||||||
gomatrixserverlib.WithSkipVerify(true),
|
gomatrixserverlib.WithSkipVerify(true),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
2
go.mod
2
go.mod
|
|
@ -22,7 +22,7 @@ require (
|
||||||
github.com/matrix-org/go-http-js-libp2p v0.0.0-20200518170932-783164aeeda4
|
github.com/matrix-org/go-http-js-libp2p v0.0.0-20200518170932-783164aeeda4
|
||||||
github.com/matrix-org/go-sqlite3-js v0.0.0-20200522092705-bc8506ccbcf3
|
github.com/matrix-org/go-sqlite3-js v0.0.0-20200522092705-bc8506ccbcf3
|
||||||
github.com/matrix-org/gomatrix v0.0.0-20200827122206-7dd5e2a05bcd
|
github.com/matrix-org/gomatrix v0.0.0-20200827122206-7dd5e2a05bcd
|
||||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20210122152215-bac0b25a32bb
|
github.com/matrix-org/gomatrixserverlib v0.0.0-20210122154608-a38974bd8a37
|
||||||
github.com/matrix-org/naffka v0.0.0-20200901083833-bcdd62999a91
|
github.com/matrix-org/naffka v0.0.0-20200901083833-bcdd62999a91
|
||||||
github.com/matrix-org/util v0.0.0-20200807132607-55161520e1d4
|
github.com/matrix-org/util v0.0.0-20200807132607-55161520e1d4
|
||||||
github.com/mattn/go-sqlite3 v1.14.2
|
github.com/mattn/go-sqlite3 v1.14.2
|
||||||
|
|
|
||||||
4
go.sum
4
go.sum
|
|
@ -567,8 +567,8 @@ github.com/matrix-org/gomatrix v0.0.0-20190528120928-7df988a63f26 h1:Hr3zjRsq2bh
|
||||||
github.com/matrix-org/gomatrix v0.0.0-20190528120928-7df988a63f26/go.mod h1:3fxX6gUjWyI/2Bt7J1OLhpCzOfO/bB3AiX0cJtEKud0=
|
github.com/matrix-org/gomatrix v0.0.0-20190528120928-7df988a63f26/go.mod h1:3fxX6gUjWyI/2Bt7J1OLhpCzOfO/bB3AiX0cJtEKud0=
|
||||||
github.com/matrix-org/gomatrix v0.0.0-20200827122206-7dd5e2a05bcd h1:xVrqJK3xHREMNjwjljkAUaadalWc0rRbmVuQatzmgwg=
|
github.com/matrix-org/gomatrix v0.0.0-20200827122206-7dd5e2a05bcd h1:xVrqJK3xHREMNjwjljkAUaadalWc0rRbmVuQatzmgwg=
|
||||||
github.com/matrix-org/gomatrix v0.0.0-20200827122206-7dd5e2a05bcd/go.mod h1:/gBX06Kw0exX1HrwmoBibFA98yBk/jxKpGVeyQbff+s=
|
github.com/matrix-org/gomatrix v0.0.0-20200827122206-7dd5e2a05bcd/go.mod h1:/gBX06Kw0exX1HrwmoBibFA98yBk/jxKpGVeyQbff+s=
|
||||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20210122152215-bac0b25a32bb h1:MX7tiRcySN9C7UFNk19ocebyGKc4NuTxnwosMAUblrc=
|
github.com/matrix-org/gomatrixserverlib v0.0.0-20210122154608-a38974bd8a37 h1:si2CZZpwOLWZfDXfgHPkaTlaAkdJvpJzr1zVqyKXd0I=
|
||||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20210122152215-bac0b25a32bb/go.mod h1:JsAzE1Ll3+gDWS9JSUHPJiiyAksvOOnGWF2nXdg4ZzU=
|
github.com/matrix-org/gomatrixserverlib v0.0.0-20210122154608-a38974bd8a37/go.mod h1:JsAzE1Ll3+gDWS9JSUHPJiiyAksvOOnGWF2nXdg4ZzU=
|
||||||
github.com/matrix-org/naffka v0.0.0-20200901083833-bcdd62999a91 h1:HJ6U3S3ljJqNffYMcIeAncp5qT/i+ZMiJ2JC2F0aXP4=
|
github.com/matrix-org/naffka v0.0.0-20200901083833-bcdd62999a91 h1:HJ6U3S3ljJqNffYMcIeAncp5qT/i+ZMiJ2JC2F0aXP4=
|
||||||
github.com/matrix-org/naffka v0.0.0-20200901083833-bcdd62999a91/go.mod h1:sjyPyRxKM5uw1nD2cJ6O2OxI6GOqyVBfNXqKjBZTBZE=
|
github.com/matrix-org/naffka v0.0.0-20200901083833-bcdd62999a91/go.mod h1:sjyPyRxKM5uw1nD2cJ6O2OxI6GOqyVBfNXqKjBZTBZE=
|
||||||
github.com/matrix-org/util v0.0.0-20190711121626-527ce5ddefc7 h1:ntrLa/8xVzeSs8vHFHK25k0C+NV74sYMJnNSg5NoSRo=
|
github.com/matrix-org/util v0.0.0-20190711121626-527ce5ddefc7 h1:ntrLa/8xVzeSs8vHFHK25k0C+NV74sYMJnNSg5NoSRo=
|
||||||
|
|
|
||||||
|
|
@ -106,7 +106,7 @@ func (t *roundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||||
func newFedClient(tripper func(*http.Request) (*http.Response, error)) *gomatrixserverlib.FederationClient {
|
func newFedClient(tripper func(*http.Request) (*http.Response, error)) *gomatrixserverlib.FederationClient {
|
||||||
_, pkey, _ := ed25519.GenerateKey(nil)
|
_, pkey, _ := ed25519.GenerateKey(nil)
|
||||||
fedClient := gomatrixserverlib.NewFederationClient(
|
fedClient := gomatrixserverlib.NewFederationClient(
|
||||||
gomatrixserverlib.ServerName("example.test"), gomatrixserverlib.KeyID("ed25519:test"), pkey, true,
|
gomatrixserverlib.ServerName("example.test"), gomatrixserverlib.KeyID("ed25519:test"), pkey,
|
||||||
)
|
)
|
||||||
fedClient.Client = *gomatrixserverlib.NewClient(
|
fedClient.Client = *gomatrixserverlib.NewClient(
|
||||||
gomatrixserverlib.WithTransport(&roundTripper{tripper}),
|
gomatrixserverlib.WithTransport(&roundTripper{tripper}),
|
||||||
|
|
|
||||||
|
|
@ -270,13 +270,12 @@ func (b *BaseDendrite) CreateClient() *gomatrixserverlib.Client {
|
||||||
gomatrixserverlib.WithTransport(noOpHTTPTransport),
|
gomatrixserverlib.WithTransport(noOpHTTPTransport),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
opts := []gomatrixserverlib.ClientOption{}
|
opts := []gomatrixserverlib.ClientOption{
|
||||||
|
gomatrixserverlib.WithSkipVerify(b.Cfg.FederationSender.DisableTLSValidation),
|
||||||
|
}
|
||||||
if b.Cfg.Global.DNSCache.Enabled {
|
if b.Cfg.Global.DNSCache.Enabled {
|
||||||
opts = append(opts, gomatrixserverlib.WithDNSCache(b.DNSCache))
|
opts = append(opts, gomatrixserverlib.WithDNSCache(b.DNSCache))
|
||||||
}
|
}
|
||||||
if validation := b.Cfg.FederationSender.DisableTLSValidation; validation {
|
|
||||||
opts = append(opts, gomatrixserverlib.WithSkipVerify(validation))
|
|
||||||
}
|
|
||||||
client := gomatrixserverlib.NewClient(opts...)
|
client := gomatrixserverlib.NewClient(opts...)
|
||||||
client.SetUserAgent(fmt.Sprintf("Dendrite/%s", internal.VersionString()))
|
client.SetUserAgent(fmt.Sprintf("Dendrite/%s", internal.VersionString()))
|
||||||
return client
|
return client
|
||||||
|
|
@ -287,20 +286,20 @@ func (b *BaseDendrite) CreateClient() *gomatrixserverlib.Client {
|
||||||
func (b *BaseDendrite) CreateFederationClient() *gomatrixserverlib.FederationClient {
|
func (b *BaseDendrite) CreateFederationClient() *gomatrixserverlib.FederationClient {
|
||||||
if b.Cfg.Global.DisableFederation {
|
if b.Cfg.Global.DisableFederation {
|
||||||
return gomatrixserverlib.NewFederationClient(
|
return gomatrixserverlib.NewFederationClient(
|
||||||
b.Cfg.Global.ServerName, b.Cfg.Global.KeyID,
|
b.Cfg.Global.ServerName, b.Cfg.Global.KeyID, b.Cfg.Global.PrivateKey,
|
||||||
b.Cfg.Global.PrivateKey, b.Cfg.FederationSender.DisableTLSValidation,
|
|
||||||
gomatrixserverlib.WithTransport(noOpHTTPTransport),
|
gomatrixserverlib.WithTransport(noOpHTTPTransport),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
opts := []gomatrixserverlib.ClientOption{
|
opts := []gomatrixserverlib.ClientOption{
|
||||||
gomatrixserverlib.WithTimeout(time.Minute * 5),
|
gomatrixserverlib.WithTimeout(time.Minute * 5),
|
||||||
|
gomatrixserverlib.WithSkipVerify(b.Cfg.FederationSender.DisableTLSValidation),
|
||||||
}
|
}
|
||||||
if b.Cfg.Global.DNSCache.Enabled {
|
if b.Cfg.Global.DNSCache.Enabled {
|
||||||
opts = append(opts, gomatrixserverlib.WithDNSCache(b.DNSCache))
|
opts = append(opts, gomatrixserverlib.WithDNSCache(b.DNSCache))
|
||||||
}
|
}
|
||||||
client := gomatrixserverlib.NewFederationClient(
|
client := gomatrixserverlib.NewFederationClient(
|
||||||
b.Cfg.Global.ServerName, b.Cfg.Global.KeyID, b.Cfg.Global.PrivateKey,
|
b.Cfg.Global.ServerName, b.Cfg.Global.KeyID,
|
||||||
b.Cfg.FederationSender.DisableTLSValidation, opts...,
|
b.Cfg.Global.PrivateKey, opts...,
|
||||||
)
|
)
|
||||||
client.SetUserAgent(fmt.Sprintf("Dendrite/%s", internal.VersionString()))
|
client.SetUserAgent(fmt.Sprintf("Dendrite/%s", internal.VersionString()))
|
||||||
return client
|
return client
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ func TestMain(m *testing.M) {
|
||||||
|
|
||||||
// Create the federation client.
|
// Create the federation client.
|
||||||
s.fedclient = gomatrixserverlib.NewFederationClient(
|
s.fedclient = gomatrixserverlib.NewFederationClient(
|
||||||
s.config.Matrix.ServerName, serverKeyID, testPriv, true,
|
s.config.Matrix.ServerName, serverKeyID, testPriv,
|
||||||
gomatrixserverlib.WithTransport(transport),
|
gomatrixserverlib.WithTransport(transport),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue