Skip to content

Commit

Permalink
Merge pull request #48 from rveachkc/develop
Browse files Browse the repository at this point in the history
Added verify parameter for requests.post
  • Loading branch information
rveachkc authored Jul 18, 2019
2 parents 1370961 + 569e1cc commit 79d8a7b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,21 @@ pytest
```

This will send two MS Teams messages describing how they are formatted. Manually validate that the message comes through as expected.

## Certificate Validation

In some situations, a custom CA bundle must be used. This can be set on class initialization, by setting the verify parameter.

```python
import pymsteams

# set custom ca bundle
msg = pymsteams.connectorcard("<Microsoft Webhook URL>", verify="/path/to/file")

# disable CA validation
msg = pymsteams.connectorcard("<Microsoft Webhook URL>", verify=False)
```

Set to either the path of a custom CA bundle or False to disable.

The requests documentation can be referenced for full details: https://2.python-requests.org/en/master/user/advanced/#ssl-cert-verification
4 changes: 3 additions & 1 deletion pymsteams/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,18 +195,20 @@ def send(self):
headers=headers,
proxies=self.proxies,
timeout=self.http_timeout,
verify=self.verify,
)

if r.status_code == requests.codes.ok:
return True
else:
raise TeamsWebhookException(r.text)

def __init__(self, hookurl, http_proxy=None, https_proxy=None, http_timeout=60):
def __init__(self, hookurl, http_proxy=None, https_proxy=None, http_timeout=60, verify=None):
self.payload = {}
self.hookurl = hookurl
self.proxies = {}
self.http_timeout = http_timeout
self.verify = verify

if http_proxy:
self.proxies['http'] = http_proxy
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from setuptools import setup
from setuptools.command.install import install

VERSION = "0.1.11"
VERSION = "0.1.12"

def readme():
""" print long description """
Expand Down

0 comments on commit 79d8a7b

Please sign in to comment.