diff options
author | Richard van der Hoff <1389908+richvdh@users.noreply.github.com> | 2019-11-01 14:07:44 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-01 14:07:44 +0000 |
commit | 1cb84c6486a5131dd284f341bb657434becda255 (patch) | |
tree | 46478781ad86d153733fbe2fdf1c556d748dcfa0 /tests/http/__init__.py | |
parent | Remove last usages of deprecated logging.warn method (#6314) (diff) | |
download | synapse-1cb84c6486a5131dd284f341bb657434becda255.tar.xz |
Support for routing outbound HTTP requests via a proxy (#6239)
The `http_proxy` and `HTTPS_PROXY` env vars can be set to a `host[:port]` value which should point to a proxy. The address of the proxy should be excluded from IP blacklists such as the `url_preview_ip_range_blacklist`. The proxy will then be used for * push * url previews * phone-home stats * recaptcha validation * CAS auth validation It will *not* be used for: * Application Services * Identity servers * Outbound federation * In worker configurations, connections from workers to masters Fixes #4198.
Diffstat (limited to 'tests/http/__init__.py')
-rw-r--r-- | tests/http/__init__.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/http/__init__.py b/tests/http/__init__.py index 2d5dba6464..2096ba3c91 100644 --- a/tests/http/__init__.py +++ b/tests/http/__init__.py @@ -20,6 +20,23 @@ from zope.interface import implementer from OpenSSL import SSL from OpenSSL.SSL import Connection from twisted.internet.interfaces import IOpenSSLServerConnectionCreator +from twisted.internet.ssl import Certificate, trustRootFromCertificates +from twisted.web.client import BrowserLikePolicyForHTTPS # noqa: F401 +from twisted.web.iweb import IPolicyForHTTPS # noqa: F401 + + +def get_test_https_policy(): + """Get a test IPolicyForHTTPS which trusts the test CA cert + + Returns: + IPolicyForHTTPS + """ + ca_file = get_test_ca_cert_file() + with open(ca_file) as stream: + content = stream.read() + cert = Certificate.loadPEM(content) + trust_root = trustRootFromCertificates([cert]) + return BrowserLikePolicyForHTTPS(trustRoot=trust_root) def get_test_ca_cert_file(): |