Skip to content

Commit 745cd96

Browse files
authored
Use get("SSL_CERT_FILE") instead of index access (#55)
This logic should be a noop in case the env does not exist, but index access can raise an exception, so lets fix this.
1 parent 1577899 commit 745cd96

3 files changed

Lines changed: 7 additions & 3 deletions

File tree

splunklib/ai/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ add the following snippet to your code:
504504

505505
```py
506506
CA_TRUST_STORE = "/opt/splunk/openssl/cert.pem"
507-
if os.environ["SSL_CERT_FILE"] == CA_TRUST_STORE and not os.path.exists(CA_TRUST_STORE):
507+
if os.environ.get("SSL_CERT_FILE") == CA_TRUST_STORE and not os.path.exists(CA_TRUST_STORE):
508508
os.environ["SSL_CERT_FILE"] = ""
509509
```
510510

tests/system/test_apps/ai_agentic_test_app/bin/agentic_endpoint.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@
3232
# does not exist on the filesystem. As a workaround in such case if it does not exist,
3333
# remove the env, this causes the default CAs to be used instead.
3434
CA_TRUST_STORE = "/opt/splunk/openssl/cert.pem"
35-
if os.environ["SSL_CERT_FILE"] == CA_TRUST_STORE and not os.path.exists(CA_TRUST_STORE):
35+
if os.environ.get("SSL_CERT_FILE") == CA_TRUST_STORE and not os.path.exists(
36+
CA_TRUST_STORE
37+
):
3638
os.environ["SSL_CERT_FILE"] = ""
3739

3840

tests/system/test_apps/ai_agentic_test_local_tools_app/bin/agentic_app_tools_endpoint.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@
3333
# does not exist on the filesystem. As a workaround in such case if it does not exist,
3434
# remove the env, this causes the default CAs to be used instead.
3535
CA_TRUST_STORE = "/opt/splunk/openssl/cert.pem"
36-
if os.environ["SSL_CERT_FILE"] == CA_TRUST_STORE and not os.path.exists(CA_TRUST_STORE):
36+
if os.environ.get("SSL_CERT_FILE") == CA_TRUST_STORE and not os.path.exists(
37+
CA_TRUST_STORE
38+
):
3739
os.environ["SSL_CERT_FILE"] = ""
3840

3941

0 commit comments

Comments
 (0)