Skip to content

Commit

Permalink
lxd plugins and modules: fix TLS/SSL context creation (#6034)
Browse files Browse the repository at this point in the history
Use correct purpose.
  • Loading branch information
felixfontein authored Feb 25, 2023
1 parent 682c6fc commit f0529dc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions changelogs/fragments/6034-lxd-tls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- "lxd_* modules, lxd inventory plugin - fix TLS/SSL certificate validation problems by using the correct purpose when creating the TLS context (https://github.com/ansible-collections/community.general/issues/5616, https://github.com/ansible-collections/community.general/pull/6034)."
2 changes: 1 addition & 1 deletion plugins/module_utils/lxd.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def __init__(self, url, key_file=None, cert_file=None, debug=False):
self.cert_file = cert_file
self.key_file = key_file
parts = generic_urlparse(urlparse(self.url))
ctx = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
ctx = ssl.create_default_context(ssl.Purpose.SERVER_AUTH)
ctx.load_cert_chain(cert_file, keyfile=key_file)
self.connection = HTTPSConnection(parts.get('netloc'), context=ctx)
elif url.startswith('unix:'):
Expand Down

0 comments on commit f0529dc

Please sign in to comment.