Skip to content

Commit

Permalink
add proxy to dev facade
Browse files Browse the repository at this point in the history
  • Loading branch information
stewartshea committed Aug 7, 2024
1 parent 6245d01 commit 8c4e945
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
4 changes: 4 additions & 0 deletions dev_facade/RW/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@

session = None

from . import proxy

REQUEST_VERIFY=proxy.get_request_verify()


class TemporaryException(Exception):
pass
Expand Down
26 changes: 26 additions & 0 deletions dev_facade/RW/proxy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""
A file for shared functions relating to proxying requests to the RW API
"""

import os

def get_request_verify():
"""Returns the value of the REQUESTS_CA_BUNDLE environment variable, or None if it is not set"""

if os.getenv("ROBOT_DEV") == "true":
return os.getenv("REQUESTS_CA_BUNDLE", None)
# If we're not in a dev environment, we need to use a workaround to handle the REQUESTS_CA_BUNDLE environment variable
# for now to skip verification of the SSL certificate.
return get_request_verify_workaround()

def get_request_verify_workaround():
"""
If the REQUESTS_CA_BUNDLE environment variable is not set, returns None. otherwise return False.
This is a workaround for the fact that the requests library does not handle the REQUESTS_CA_BUNDLE
environment variable when using a venv by default. There's a potential workaround for this either
using pip-system-certs or truststore but this is a workaround for now until there's time to investigate further.
"""

if os.getenv("REQUESTS_CA_BUNDLE", None) is None:
return None
return False

0 comments on commit 8c4e945

Please sign in to comment.