Skip to content
This repository was archived by the owner on Dec 5, 2025. It is now read-only.

Commit aacf970

Browse files
authored
[client] Add mTLS support and update isort (#363)
1 parent ca42db7 commit aacf970

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
repos:
33
- repo: https://github.com/PyCQA/isort
4-
rev: 5.10.1
4+
rev: 5.12.0
55
hooks:
66
- id: isort
77
args:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ $ pip install -r ./test-requirements.txt
7575
#### Prerequisite
7676

7777
Your OpenCTI API should be running.
78-
Your conftest.py should be configured with your API url and your token.
78+
Your conftest.py should be configured with your API url, your token, and if applicable, your mTLS cert/key.
7979

8080
#### Launching
8181

docs/client_usage/getting_started.rst

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,13 @@ Using the helper functions
1212
**************************
1313

1414
The main class :class:`OpenCTIApiClient` contains all what you need to interact
15-
with the platform, you just have to initialize it. The following example shows
16-
how you create an indicator in OpenCTI using the python library with TLP marking
17-
and OpenCTI compatible date format.
15+
with the platform, you just have to initialize it. If your OpenCTI instance requires mTLS,
16+
you can specify the paths to your cert and private key in a tuple with the `cert` parameter when
17+
initializing the `OpenCTIApiClient`. If you need to specify a path to a CA root certificate,
18+
you can do so with the `ssl_verify` parameter.
19+
20+
The following example shows how you create an indicator in OpenCTI using the python library
21+
with TLP marking and OpenCTI compatible date format.
1822

1923
.. code-block:: python
2024

pycti/api/opencti_api_client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,13 @@ def __init__(
117117
ssl_verify=False,
118118
proxies=None,
119119
json_logging=False,
120+
cert=None,
120121
):
121122
"""Constructor method"""
122123

123124
# Check configuration
124125
self.ssl_verify = ssl_verify
126+
self.cert = cert
125127
self.proxies = proxies
126128
if url is None or len(url) == 0:
127129
raise ValueError("An URL must be set")
@@ -315,6 +317,7 @@ def query(self, query, variables={}):
315317
files=multipart_files,
316318
headers=self.request_headers,
317319
verify=self.ssl_verify,
320+
cert=self.cert,
318321
proxies=self.proxies,
319322
)
320323
# If no
@@ -324,6 +327,7 @@ def query(self, query, variables={}):
324327
json={"query": query, "variables": variables},
325328
headers=self.request_headers,
326329
verify=self.ssl_verify,
330+
cert=self.cert,
327331
proxies=self.proxies,
328332
)
329333
# Build response

0 commit comments

Comments
 (0)