Skip to content

Gitlab.from_config doesn't allow string ssl_verify #270

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mdhausman opened this issue Jun 2, 2017 · 2 comments
Closed

Gitlab.from_config doesn't allow string ssl_verify #270

mdhausman opened this issue Jun 2, 2017 · 2 comments

Comments

@mdhausman
Copy link

mdhausman commented Jun 2, 2017

For many users who are working with self-signed certs, ssl verification can be troublesome. I found that while I could use python-gitlab with our internal certs, I can't do it from a configuration file.

For instance, this works:

gitlab_dao = gitlab.Gitlab('https://our.gitlab.location', private_token='somethingprivate', ssl_verify='/our/companys/internal/certs/cert.crt')

But when I tried to set up a config file like

[global]
default = https://our.gitlab.location
ssl_verify = /our/companys/internal/certs/cert.crt
timeout = 5
api_version = 3

[somewhere]
url = https://our.gitlab.location
private_token = somethingprivate

And call it with gitlab_dao = gitlab.Gitlab.from_config('somewhere', ['my-config.cfg']), it would break on gitlab_dao.auth().

Some debugging led me to the reason: GitlabConfigParser line 66: self.ssl_verify = self._config.getboolean(self.gitlab_id, 'ssl_verify')

Because it's only looking for a boolean, it throws an exception here and sets ssl_verify to True. This kills the internal cert.

@mdhausman
Copy link
Author

I've got a hacky workaround in the meantime:

gitlab_dao = gitlab.Gitlab.from_config('somewhere', ['my-config.cfg'])
gitlab_dao.ssl_verify = '/our/companys/internal/certs/cert.crt'
gitlab_dao.auth()

@mdhausman
Copy link
Author

mdhausman commented Jun 2, 2017

I can probably make a pull request to handle this within the next few weeks. Shouldn't be hard.

I'm thinking leave line 66 as-is, but on exception it should instead try to self._config.get(self.gitlab_id, 'ssl_verify'). If it's a falsy return (or yet another exception), default back to True. Then a little update to test_config.py and we're good.

mdhausman pushed a commit to wayfair-archive/python-gitlab that referenced this issue Jul 24, 2017
mdhausman pushed a commit to wayfair-archive/python-gitlab that referenced this issue Jul 24, 2017
mdhausman pushed a commit to wayfair-archive/python-gitlab that referenced this issue Jul 31, 2017
mdhausman pushed a commit to wayfair-archive/python-gitlab that referenced this issue Aug 1, 2017
mdhausman pushed a commit to wayfair-archive/python-gitlab that referenced this issue Aug 1, 2017
mdhausman pushed a commit to wayfair-archive/python-gitlab that referenced this issue Aug 3, 2017
mdhausman pushed a commit to wayfair-archive/python-gitlab that referenced this issue Aug 3, 2017
mdhausman pushed a commit to wayfair-archive/python-gitlab that referenced this issue Aug 4, 2017
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants