mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-18 04:13:10 -06:00
Fix#609
This commit is contained in:
parent
0352f250b8
commit
de86bfa454
|
|
@ -19,14 +19,17 @@ package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"crypto/tls"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/matrix-org/dendrite/clientapi/auth/authtypes"
|
"github.com/matrix-org/dendrite/clientapi/auth/authtypes"
|
||||||
"github.com/matrix-org/dendrite/clientapi/auth/storage/accounts"
|
"github.com/matrix-org/dendrite/clientapi/auth/storage/accounts"
|
||||||
"github.com/matrix-org/gomatrixserverlib"
|
"github.com/matrix-org/gomatrixserverlib"
|
||||||
|
|
||||||
"github.com/matrix-org/dendrite/common"
|
"github.com/matrix-org/dendrite/common"
|
||||||
|
"github.com/matrix-org/dendrite/common/config"
|
||||||
commonHTTP "github.com/matrix-org/dendrite/common/http"
|
commonHTTP "github.com/matrix-org/dendrite/common/http"
|
||||||
opentracing "github.com/opentracing/opentracing-go"
|
opentracing "github.com/opentracing/opentracing-go"
|
||||||
)
|
)
|
||||||
|
|
@ -99,13 +102,20 @@ type httpAppServiceQueryAPI struct {
|
||||||
// to a HTTP POST API.
|
// to a HTTP POST API.
|
||||||
// If httpClient is nil then it uses http.DefaultClient
|
// If httpClient is nil then it uses http.DefaultClient
|
||||||
func NewAppServiceQueryAPIHTTP(
|
func NewAppServiceQueryAPIHTTP(
|
||||||
appserviceURL string,
|
Cfg *config.Dendrite,
|
||||||
httpClient *http.Client,
|
httpClient *http.Client,
|
||||||
) AppServiceQueryAPI {
|
) AppServiceQueryAPI {
|
||||||
if httpClient == nil {
|
if httpClient == nil {
|
||||||
httpClient = http.DefaultClient
|
customTransport := http.DefaultTransport.(*http.Transport).Clone()
|
||||||
|
if Cfg.Test.SkipSSLVerify == true {
|
||||||
|
customTransport.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
|
||||||
|
}
|
||||||
|
httpClient = &http.Client{
|
||||||
|
Timeout: time.Second * 30,
|
||||||
|
Transport: customTransport,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return &httpAppServiceQueryAPI{appserviceURL, httpClient}
|
return &httpAppServiceQueryAPI{Cfg.AppServiceURL(), httpClient}
|
||||||
}
|
}
|
||||||
|
|
||||||
// RoomAliasExists implements AppServiceQueryAPI
|
// RoomAliasExists implements AppServiceQueryAPI
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ package appservice
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"crypto/tls"
|
||||||
"net/http"
|
"net/http"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
@ -82,6 +83,14 @@ func SetupAppServiceAPIComponent(
|
||||||
},
|
},
|
||||||
Cfg: base.Cfg,
|
Cfg: base.Cfg,
|
||||||
}
|
}
|
||||||
|
if base.Cfg.Test.SkipSSLVerify == true {
|
||||||
|
customTransport := http.DefaultTransport.(*http.Transport).Clone()
|
||||||
|
customTransport.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
|
||||||
|
appserviceQueryAPI.HTTPClient = &http.Client{
|
||||||
|
Transport: customTransport,
|
||||||
|
Timeout: time.Second * 30,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
appserviceQueryAPI.SetupHTTP(http.DefaultServeMux)
|
appserviceQueryAPI.SetupHTTP(http.DefaultServeMux)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ package query
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"crypto/tls"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
@ -52,7 +53,7 @@ func (a *AppServiceQueryAPI) RoomAliasExists(
|
||||||
|
|
||||||
// Create an HTTP client if one does not already exist
|
// Create an HTTP client if one does not already exist
|
||||||
if a.HTTPClient == nil {
|
if a.HTTPClient == nil {
|
||||||
a.HTTPClient = makeHTTPClient()
|
a.HTTPClient = makeHTTPClient(a.Cfg.Test.SkipSSLVerify)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine which application service should handle this request
|
// Determine which application service should handle this request
|
||||||
|
|
@ -120,7 +121,7 @@ func (a *AppServiceQueryAPI) UserIDExists(
|
||||||
|
|
||||||
// Create an HTTP client if one does not already exist
|
// Create an HTTP client if one does not already exist
|
||||||
if a.HTTPClient == nil {
|
if a.HTTPClient == nil {
|
||||||
a.HTTPClient = makeHTTPClient()
|
a.HTTPClient = makeHTTPClient(a.Cfg.Test.SkipSSLVerify)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine which application service should handle this request
|
// Determine which application service should handle this request
|
||||||
|
|
@ -174,9 +175,14 @@ func (a *AppServiceQueryAPI) UserIDExists(
|
||||||
}
|
}
|
||||||
|
|
||||||
// makeHTTPClient creates an HTTP client with certain options that will be used for all query requests to application services
|
// makeHTTPClient creates an HTTP client with certain options that will be used for all query requests to application services
|
||||||
func makeHTTPClient() *http.Client {
|
func makeHTTPClient(skipSSLVerify bool) *http.Client {
|
||||||
|
customTransport := http.DefaultTransport.(*http.Transport).Clone()
|
||||||
|
if skipSSLVerify == true {
|
||||||
|
customTransport.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
|
||||||
|
}
|
||||||
return &http.Client{
|
return &http.Client{
|
||||||
Timeout: time.Second * 30,
|
Transport: customTransport,
|
||||||
|
Timeout: time.Second * 30,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ package threepid
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"crypto/tls"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
@ -226,6 +227,14 @@ func queryIDServerStoreInvite(
|
||||||
}
|
}
|
||||||
|
|
||||||
client := http.Client{}
|
client := http.Client{}
|
||||||
|
if cfg.Test.SkipSSLVerify == true {
|
||||||
|
customTransport := http.DefaultTransport.(*http.Transport).Clone()
|
||||||
|
customTransport.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
|
||||||
|
client = http.Client{
|
||||||
|
Transport: customTransport,
|
||||||
|
Timeout: time.Second * 30,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
data := url.Values{}
|
data := url.Values{}
|
||||||
data.Add("medium", body.Medium)
|
data.Add("medium", body.Medium)
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ package threepid
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"crypto/tls"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
@ -23,6 +24,7 @@ import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/matrix-org/dendrite/common/config"
|
"github.com/matrix-org/dendrite/common/config"
|
||||||
)
|
)
|
||||||
|
|
@ -74,6 +76,14 @@ func CreateSession(
|
||||||
request.Header.Add("Content-Type", "application/x-www-form-urlencoded")
|
request.Header.Add("Content-Type", "application/x-www-form-urlencoded")
|
||||||
|
|
||||||
client := http.Client{}
|
client := http.Client{}
|
||||||
|
if cfg.Test.SkipSSLVerify == true {
|
||||||
|
customTransport := http.DefaultTransport.(*http.Transport).Clone()
|
||||||
|
customTransport.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
|
||||||
|
client = http.Client{
|
||||||
|
Transport: customTransport,
|
||||||
|
Timeout: time.Second * 30,
|
||||||
|
}
|
||||||
|
}
|
||||||
resp, err := client.Do(request.WithContext(ctx))
|
resp, err := client.Do(request.WithContext(ctx))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
|
@ -161,6 +171,14 @@ func PublishAssociation(creds Credentials, userID string, cfg *config.Dendrite)
|
||||||
request.Header.Add("Content-Type", "application/x-www-form-urlencoded")
|
request.Header.Add("Content-Type", "application/x-www-form-urlencoded")
|
||||||
|
|
||||||
client := http.Client{}
|
client := http.Client{}
|
||||||
|
if cfg.Test.SkipSSLVerify == true {
|
||||||
|
customTransport := http.DefaultTransport.(*http.Transport).Clone()
|
||||||
|
customTransport.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
|
||||||
|
client = http.Client{
|
||||||
|
Transport: customTransport,
|
||||||
|
Timeout: time.Second * 30,
|
||||||
|
}
|
||||||
|
}
|
||||||
resp, err := client.Do(request)
|
resp, err := client.Do(request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ func (b *BaseDendrite) Close() error {
|
||||||
// CreateHTTPAppServiceAPIs returns the QueryAPI for hitting the appservice
|
// CreateHTTPAppServiceAPIs returns the QueryAPI for hitting the appservice
|
||||||
// component over HTTP.
|
// component over HTTP.
|
||||||
func (b *BaseDendrite) CreateHTTPAppServiceAPIs() appserviceAPI.AppServiceQueryAPI {
|
func (b *BaseDendrite) CreateHTTPAppServiceAPIs() appserviceAPI.AppServiceQueryAPI {
|
||||||
return appserviceAPI.NewAppServiceQueryAPIHTTP(b.Cfg.AppServiceURL(), nil)
|
return appserviceAPI.NewAppServiceQueryAPIHTTP(b.Cfg, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateHTTPRoomserverAPIs returns the AliasAPI, InputAPI and QueryAPI for hitting
|
// CreateHTTPRoomserverAPIs returns the AliasAPI, InputAPI and QueryAPI for hitting
|
||||||
|
|
|
||||||
|
|
@ -268,6 +268,10 @@ type Dendrite struct {
|
||||||
// Note: An Exclusive Regex for room ID isn't necessary as we aren't blocking
|
// Note: An Exclusive Regex for room ID isn't necessary as we aren't blocking
|
||||||
// servers from creating RoomIDs in exclusive application service namespaces
|
// servers from creating RoomIDs in exclusive application service namespaces
|
||||||
} `yaml:"-"`
|
} `yaml:"-"`
|
||||||
|
|
||||||
|
Test struct {
|
||||||
|
SkipSSLVerify bool `yaml:"skip_verify_SSL_certificates"`
|
||||||
|
} `yaml:"test"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// A Path on the filesystem.
|
// A Path on the filesystem.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue