Skip to content
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

Passing a SSL Cert to the requests library #64

Closed
williehallock802 opened this issue Nov 27, 2019 · 4 comments · Fixed by #82
Closed

Passing a SSL Cert to the requests library #64

williehallock802 opened this issue Nov 27, 2019 · 4 comments · Fixed by #82

Comments

@williehallock802
Copy link

The following code works just fine in Jupyter:

from mattermostdriver import Driver
from pprint import pprint

options = {}

options[ 'url' ]   = '<url>'
options[ 'token' ] = '<your personal token here>'
options[ 'port' ]  = 443

%env REQUESTS_CA_BUNDLE=/path/to/cert.pem

driver = Driver( options = options )
driver.login()

teamData    = driver.teams.get_team_by_name( 'teamname' )
teamID      = teamData[ 'id' ]
channelData = driver.channels.get_channel_by_name( teamID, 'roomname' )

postOptions = { 'channel_id': channelData[ 'id' ], 'message': 'mattermost test' }

driver.posts.create_post( options = postOptions )

The reason why it works is that I can specify in the environment that path to the .pem file for the requests library to use. It would be nice if there was some way to pass this path directly down to the requests library through login() or just adding stuff to the options variable, but that does not appear to be possible...unless I have missed something.

@Vaelor
Copy link
Owner

Vaelor commented Nov 28, 2019

Hi, can you try to set the verify option to the path of your CA (.pem)?
Verify can either be True or False or a path, which should do what you want.

My documentation is clearly missing that here though!

options[ 'verify' ] = '/path/to/file.pem'

@williehallock802
Copy link
Author

Yep, that worked. It would make for a good usage example for your documentation as it will likely be a fairly common case.

@dmpe
Copy link

dmpe commented Oct 1, 2020

haha, doc is still missing. the description says that it is either true or false
@Vaelor

@Vaelor
Copy link
Owner

Vaelor commented Oct 1, 2020

Oh damn xD

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants