Skip to content

Commit 96edeaa

Browse files
(chore) conform to Black formatting standards
1 parent 09400a3 commit 96edeaa

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

pycti/api/opencti_api_client.py

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -256,32 +256,34 @@ def __init__(
256256

257257
def _setup_proxy_certificates(self):
258258
"""Setup HTTPS proxy certificates from environment variable.
259-
259+
260260
Detects HTTPS_CA_CERTIFICATES environment variable and combines
261261
proxy certificates with system certificates for SSL verification.
262262
"""
263263
https_ca_certificates = os.getenv("HTTPS_CA_CERTIFICATES")
264264
if not https_ca_certificates:
265265
return
266-
266+
267267
try:
268268
# Create secure temporary directory
269269
cert_dir = tempfile.mkdtemp(prefix="opencti_proxy_certs_")
270-
270+
271271
# Write proxy certificate to temp file
272272
proxy_cert_file = os.path.join(cert_dir, "proxy-ca.crt")
273273
with open(proxy_cert_file, "w") as f:
274274
f.write(https_ca_certificates)
275-
275+
276276
# Find system certificates
277277
system_cert_paths = [
278278
"/etc/ssl/certs/ca-certificates.crt", # Debian/Ubuntu
279-
"/etc/pki/tls/certs/ca-bundle.crt", # RHEL/CentOS
280-
"/etc/ssl/cert.pem", # Alpine/BSD
279+
"/etc/pki/tls/certs/ca-bundle.crt", # RHEL/CentOS
280+
"/etc/ssl/cert.pem", # Alpine/BSD
281281
]
282-
282+
283283
# Create combined certificate bundle
284-
combined_cert_file = os.path.join(cert_dir, "combined-ca-bundle.crt")
284+
combined_cert_file = os.path.join(
285+
cert_dir, "combined-ca-bundle.crt"
286+
)
285287
with open(combined_cert_file, "w") as combined:
286288
# Add system certificates first
287289
for system_path in system_cert_paths:
@@ -290,25 +292,26 @@ def _setup_proxy_certificates(self):
290292
combined.write(sys_certs.read())
291293
combined.write("\n")
292294
break
293-
295+
294296
# Add proxy certificate
295297
combined.write(https_ca_certificates)
296-
298+
297299
# Update ssl_verify to use combined certificate bundle
298300
self.ssl_verify = combined_cert_file
299-
301+
300302
# Set environment variables for urllib and other libraries
301303
os.environ["REQUESTS_CA_BUNDLE"] = combined_cert_file
302304
os.environ["SSL_CERT_FILE"] = combined_cert_file
303-
304-
self.app_logger.info("Proxy certificates configured", {
305-
"cert_bundle": combined_cert_file
306-
})
307-
305+
306+
self.app_logger.info(
307+
"Proxy certificates configured",
308+
{"cert_bundle": combined_cert_file},
309+
)
310+
308311
except Exception as e:
309-
self.app_logger.warning("Failed to setup proxy certificates", {
310-
"error": str(e)
311-
})
312+
self.app_logger.warning(
313+
"Failed to setup proxy certificates", {"error": str(e)}
314+
)
312315

313316
def set_applicant_id_header(self, applicant_id):
314317
self.request_headers["opencti-applicant-id"] = applicant_id

0 commit comments

Comments
 (0)