From bde62d79a47b3c176ed7f18e38442cda95a17f88 Mon Sep 17 00:00:00 2001 From: Vladimir Kaspar Date: Thu, 15 Apr 2021 21:29:56 +0200 Subject: [PATCH] [7.x] Add client_cert and client_key support to AIOHttpConnection --- elasticsearch/_async/http_aiohttp.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/elasticsearch/_async/http_aiohttp.py b/elasticsearch/_async/http_aiohttp.py index 3bbdffcc..7b581383 100644 --- a/elasticsearch/_async/http_aiohttp.py +++ b/elasticsearch/_async/http_aiohttp.py @@ -205,6 +205,16 @@ class AIOHttpConnection(AsyncConnection): else: raise ImproperlyConfigured("ca_certs parameter is not a path") + # Use client_cert and client_key variables for SSL certificate configuration. + if client_cert and not os.path.isfile(client_cert): + raise ImproperlyConfigured("client_cert is not a path to a file") + if client_key and not os.path.isfile(client_key): + raise ImproperlyConfigured("client_key is not a path to a file") + if client_cert and client_key: + ssl_context.load_cert_chain(client_cert, client_key) + elif client_cert: + ssl_context.load_cert_chain(client_cert) + self.headers.setdefault("connection", "keep-alive") self.loop = loop self.session = None