Skip to content

Commit 0acefc7

Browse files
authored
Merge pull request #585 from splunk/VULN-17383
use SSL DEFAULT CONTEX, use tls version min 1.2, allow for usage of S…
2 parents 27296a3 + 1f2b3bc commit 0acefc7

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
uses: actions/checkout@v3
2424

2525
- name: Run docker-compose
26-
run: SPLUNK_VERSION=${{matrix.splunk-version}} docker-compose up -d
26+
run: SPLUNK_VERSION=${{matrix.splunk-version}} docker compose up -d
2727

2828
- name: Setup Python
2929
uses: actions/setup-python@v4

splunklib/binding.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,8 @@ class Context:
465465
:type scheme: "https" or "http"
466466
:param verify: Enable (True) or disable (False) SSL verification for https connections.
467467
:type verify: ``Boolean``
468+
:param self_signed_certificate: Specifies if self signed certificate is used
469+
:type self_signed_certificate: ``Boolean``
468470
:param sharing: The sharing mode for the namespace (the default is "user").
469471
:type sharing: "global", "system", "app", or "user"
470472
:param owner: The owner context of the namespace (optional, the default is "None").
@@ -526,6 +528,7 @@ def __init__(self, handler=None, **kwargs):
526528
self.bearerToken = kwargs.get("splunkToken", "")
527529
self.autologin = kwargs.get("autologin", False)
528530
self.additional_headers = kwargs.get("headers", [])
531+
self._self_signed_certificate = kwargs.get("self_signed_certificate", True)
529532

530533
# Store any cookies in the self.http._cookies dict
531534
if "cookie" in kwargs and kwargs['cookie'] not in [None, _NoAuthenticationToken]:
@@ -604,7 +607,11 @@ def connect(self):
604607
"""
605608
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
606609
if self.scheme == "https":
607-
sock = ssl.wrap_socket(sock)
610+
context = ssl.create_default_context()
611+
context.options |= ssl.OP_NO_TLSv1 | ssl.OP_NO_TLSv1_1
612+
context.check_hostname = not self._self_signed_certificate
613+
context.verify_mode = ssl.CERT_NONE if self._self_signed_certificate else ssl.CERT_REQUIRED
614+
sock = context.wrap_socket(sock, server_hostname=self.host)
608615
sock.connect((socket.gethostbyname(self.host), self.port))
609616
return sock
610617

0 commit comments

Comments
 (0)