Skip to content

Commit 60a6580

Browse files
authored
Merge branch 'opensearch-cert' of 'https://github.com/jjmerchante/grimoirelab-core'
Merges #44 Closes #44
2 parents 356527f + e470d05 commit 60a6580

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/grimoirelab/core/scheduler/tasks/archivist.py

+16-2
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@
2222
import json
2323
import logging
2424
import typing
25-
import urllib3
2625

26+
import certifi
2727
import redis
2828
import rq.job
29+
import urllib3
2930

3031
from django.conf import settings
3132
from opensearchpy import OpenSearch, RequestError
33+
from urllib3.util import create_urllib3_context
3234

3335

3436
if typing.TYPE_CHECKING:
@@ -393,7 +395,19 @@ def __init__(
393395
if user and password:
394396
auth = (user, password)
395397

396-
self.client = OpenSearch([url], http_auth=auth, verify_certs=self.verify_certs)
398+
context = None
399+
if self.verify_certs:
400+
# Use certificates from the local system and certifi
401+
context = create_urllib3_context()
402+
context.load_default_certs()
403+
context.load_verify_locations(certifi.where())
404+
405+
self.client = OpenSearch(
406+
hosts=[url],
407+
http_auth=auth,
408+
verify_certs=self.verify_certs,
409+
ssl_context=context,
410+
)
397411
self._create_index(db_name)
398412
self.max_items_bulk = 100
399413

0 commit comments

Comments
 (0)