Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maunium
synapse
Commits
81b8fded
Commit
81b8fded
authored
5 years ago
by
Richard van der Hoff
Browse files
Options
Downloads
Patches
Plain Diff
rename gutwrenched attr
parent
19780a52
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
synapse/crypto/context_factory.py
+9
-5
9 additions, 5 deletions
synapse/crypto/context_factory.py
with
9 additions
and
5 deletions
synapse/crypto/context_factory.py
+
9
−
5
View file @
81b8fded
...
...
@@ -110,8 +110,10 @@ class ClientTLSOptionsFactory(object):
tls_protocol
=
ssl_connection
.
get_app_data
()
try
:
# ... we further assume that SSLClientConnectionCreator has set the
# 'tls_verifier' attribute to a ConnectionVerifier object.
tls_protocol
.
tls_verifier
.
verify_context_info_cb
(
ssl_connection
,
where
)
# '_synapse_tls_verifier' attribute to a ConnectionVerifier object.
tls_protocol
.
_synapse_tls_verifier
.
verify_context_info_cb
(
ssl_connection
,
where
)
except
:
# noqa: E722, taken from the twisted implementation
logger
.
exception
(
"
Error during info_callback
"
)
f
=
Failure
()
...
...
@@ -124,6 +126,7 @@ class SSLClientConnectionCreator(object):
Replaces twisted.internet.ssl.ClientTLSOptions
"""
def
__init__
(
self
,
hostname
,
ctx
,
verify_certs
):
self
.
_ctx
=
ctx
self
.
_verifier
=
ConnectionVerifier
(
hostname
,
verify_certs
)
...
...
@@ -136,10 +139,10 @@ class SSLClientConnectionCreator(object):
# data to our TLSMemoryBIOProtocol...
connection
.
set_app_data
(
tls_protocol
)
# ... and we also gut-wrench a 'tls_verifier' attribute into the
# ... and we also gut-wrench a '
_synapse_
tls_verifier' attribute into the
# tls_protocol so that the SSL context's info callback has something to
# call to do the cert verification.
setattr
(
tls_protocol
,
"
tls_verifier
"
,
self
.
_verifier
)
setattr
(
tls_protocol
,
"
_synapse_
tls_verifier
"
,
self
.
_verifier
)
return
connection
...
...
@@ -149,13 +152,14 @@ class ConnectionVerifier(object):
This is a thing which is attached to the TLSMemoryBIOProtocol, and is called by
the ssl context
'
s info callback.
"""
# This code is based on twisted.internet.ssl.ClientTLSOptions.
def
__init__
(
self
,
hostname
,
verify_certs
):
self
.
_verify_certs
=
verify_certs
if
isIPAddress
(
hostname
)
or
isIPv6Address
(
hostname
):
self
.
_hostnameBytes
=
hostname
.
encode
(
'
ascii
'
)
self
.
_hostnameBytes
=
hostname
.
encode
(
"
ascii
"
)
self
.
_is_ip_address
=
True
else
:
# twisted's ClientTLSOptions falls back to the stdlib impl here if
...
...
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