Skip to content

Commit

Permalink
Merge pull request #51 from zopefoundation/load-default-cert-for-clie…
Browse files Browse the repository at this point in the history
…nt-of-signed-server

Fixed: SSL clients of servers with signed certs didn't load default
  • Loading branch information
jimfulton committed Jul 19, 2016
2 parents 51a6311 + 031ab97 commit 815f39d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Changelog
=========

- Fixed: SSL clients of servers with signed certs didn't load default
certs and were unable to connect.


5.0.0a0 (2016-07-08)
--------------------

Expand Down
4 changes: 4 additions & 0 deletions src/ZEO/tests/testssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ def test_ssl_mockiavellian_client_server_signed(
factory, context, (client_cert, client_key, None),
check_hostname=True)

context.load_default_certs.assert_called_with()

@mock.patch('ssl.create_default_context')
@mock.patch('ZEO.ClientStorage.ClientStorage')
def test_ssl_mockiavellian_client_auth_dir(
Expand All @@ -210,6 +212,7 @@ def test_ssl_mockiavellian_client_auth_dir(
capath=here,
check_hostname=True,
)
context.load_default_certs.assert_not_called()

@mock.patch('ssl.create_default_context')
@mock.patch('ZEO.ClientStorage.ClientStorage')
Expand All @@ -226,6 +229,7 @@ def test_ssl_mockiavellian_client_auth_file(
cafile=server_cert,
check_hostname=True,
)
context.load_default_certs.assert_not_called()

@mock.patch('ssl.create_default_context')
@mock.patch('ZEO.ClientStorage.ClientStorage')
Expand Down
6 changes: 5 additions & 1 deletion src/ZEO/zconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@ def ssl_config(section, server):
if auth:
if os.path.isdir(auth):
capath=auth
else:
elif auth != 'DYNAMIC':
cafile=auth

context = ssl.create_default_context(
ssl.Purpose.CLIENT_AUTH, cafile=cafile, capath=capath)

if not auth:
assert not server
context.load_default_certs()

if section.certificate:
password = section.password_function
if password:
Expand Down

0 comments on commit 815f39d

Please sign in to comment.