Skip to content
This repository was archived by the owner on Jun 3, 2021. It is now read-only.

Commit c5bd3a6

Browse files
author
Maura Hausman
committed
Support SSL verification via internal CA bundle
- See issues python-gitlab#204 and python-gitlab#270
1 parent 19f1b1a commit c5bd3a6

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

gitlab/config.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,19 @@ def __init__(self, gitlab_id=None, config_files=None):
6161
self.ssl_verify = True
6262
try:
6363
self.ssl_verify = self._config.getboolean('global', 'ssl_verify')
64+
except ValueError:
65+
# Value Error means the option exists but isn't a boolean.
66+
# Get as a string instead as it should then be a local path to a
67+
# CA bundle.
68+
self.ssl_verify = self._config.get(self.gitlab_id,
69+
'ssl_verify')
6470
except Exception:
6571
pass
6672
try:
6773
self.ssl_verify = self._config.getboolean(self.gitlab_id,
6874
'ssl_verify')
75+
except ValueError:
76+
self.ssl_verify = self._config.get(self.gitlab_id, 'ssl_verify')
6977
except Exception:
7078
pass
7179

gitlab/tests/test_config.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@
4040
private_token = GHIJKL
4141
ssl_verify = false
4242
timeout = 10
43+
44+
[three]
45+
url = https://three.url
46+
private_token = MNOPQR
47+
ssl_verify = /path/to/CA/bundle.crt
4348
"""
4449

4550
no_default_config = u"""[global]
@@ -109,3 +114,13 @@ def test_valid_data(self, m_open):
109114
self.assertEqual("GHIJKL", cp.token)
110115
self.assertEqual(10, cp.timeout)
111116
self.assertEqual(False, cp.ssl_verify)
117+
118+
fd = six.StringIO(valid_config)
119+
fd.close = mock.Mock(return_value=None)
120+
m_open.return_value = fd
121+
cp = config.GitlabConfigParser(gitlab_id="three")
122+
self.assertEqual("three", cp.gitlab_id)
123+
self.assertEqual("https://three.url", cp.url)
124+
self.assertEqual("MNOPQR", cp.token)
125+
self.assertEqual(2, cp.timeout)
126+
self.assertEqual("/path/to/CA/bundle.crt", cp.ssl_verify)

0 commit comments

Comments
 (0)