Skip to content

Commit d26b45c

Browse files
authored
Add a configuration in .ctf/config to disable ssl verification (#72)
* Add `ssl_verify` in the `.ctf/config` file to support SSL verification disabling * `ssl_verify` mimics the `verify` parameter in requests in that it can be `true` or `false` or a string (specifying the trusted SSL certificates)
1 parent 5f288fc commit d26b45c

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

ctfcli/utils/config.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,21 @@ def preview_config(as_string=False):
6363

6464
def generate_session():
6565
config = load_config()
66+
67+
# Load required configuration values
6668
url = config["config"]["url"]
6769
access_token = config["config"]["access_token"]
70+
71+
# Handle SSL verification disabling
72+
try:
73+
# Get an ssl_verify config. Default to True if it doesn't exist
74+
ssl_verify = config["config"].getboolean("ssl_verify", True)
75+
except ValueError:
76+
# If we didn't a proper boolean value we should load it as a string
77+
# https://requests.kennethreitz.org/en/master/user/advanced/#ssl-cert-verification
78+
ssl_verify = config["config"].get("ssl_verify")
79+
6880
s = APISession(prefix_url=url)
81+
s.verify = ssl_verify
6982
s.headers.update({"Authorization": f"Token {access_token}"})
7083
return s

0 commit comments

Comments
 (0)