Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Matrix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Operate
Environments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Matrix
Commits
64899341
Commit
64899341
authored
6 years ago
by
Jeroen
Browse files
Options
Downloads
Patches
Plain Diff
include private functions from twisted
parent
d5c0ce4c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
synapse/crypto/context_factory.py
+35
-2
35 additions, 2 deletions
synapse/crypto/context_factory.py
with
35 additions
and
2 deletions
synapse/crypto/context_factory.py
+
35
−
2
View file @
64899341
...
...
@@ -16,10 +16,10 @@ import logging
from
zope.interface
import
implementer
from
OpenSSL
import
SSL
,
crypto
from
twisted.internet._idna
import
_idnaBytes
from
twisted.internet._sslverify
import
_defaultCurveName
,
_tolerateErrors
from
twisted.internet._sslverify
import
_defaultCurveName
from
twisted.internet.interfaces
import
IOpenSSLClientConnectionCreator
from
twisted.internet.ssl
import
CertificateOptions
,
ContextFactory
from
twisted.python.failure
import
Failure
logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -53,6 +53,39 @@ class ServerContextFactory(ContextFactory):
return
self
.
_context
def
_idnaBytes
(
text
):
"""
Convert some text typed by a human into some ASCII bytes. This is a
copy of twisted.internet._idna._idnaBytes. For documentation, see the
twisted documentation.
"""
try
:
import
idna
except
ImportError
:
return
text
.
encode
(
"
idna
"
)
else
:
return
idna
.
encode
(
text
)
def
_tolerateErrors
(
wrapped
):
"""
Wrap up an info_callback for pyOpenSSL so that if something goes wrong
the error is immediately logged and the connection is dropped if possible.
This is a copy of twisted.internet._sslverify._tolerateErrors. For
documentation, see the twisted documentation.
"""
def
infoCallback
(
connection
,
where
,
ret
):
try
:
return
wrapped
(
connection
,
where
,
ret
)
except
:
# noqa: E722, taken from the twisted implementation
f
=
Failure
()
logger
.
exception
(
"
Error during info_callback
"
)
connection
.
get_app_data
().
failVerification
(
f
)
return
infoCallback
@implementer
(
IOpenSSLClientConnectionCreator
)
class
ClientTLSOptions
(
object
):
"""
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment