Skip to content

Commit

Permalink
SSL Certificate Checking now an option via ?verify= - fixes #19
Browse files Browse the repository at this point in the history
  • Loading branch information
caronc committed Jul 5, 2017
1 parent fdd4acf commit b15e39f
Show file tree
Hide file tree
Showing 17 changed files with 70 additions and 15 deletions.
3 changes: 3 additions & 0 deletions Notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,9 @@ def notify(self, servers, body, title, notify_type):
# Base
'include_image': include_image,
'secure': (server['schema'][-1] == 's'),
# Support SSL Certificate 'verify' keyword
# Default to being enabled (True)
'verify': self.parse_bool(server['qsd'].get('verify', True)),
# Overrides
'override_image_url': image_url,
'override_image_path': image_path,
Expand Down
3 changes: 3 additions & 0 deletions Notify/pnotify/NotifyBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ def __init__(self, title_maxlen=100, body_maxlen=512,
self.include_image = include_image
self.secure = secure

# Certificate Verification (for SSL calls); default to being enabled
self.verify_certificate = kwargs.get('verify', True)

self.host = kwargs.get('host', '')
self.port = kwargs.get('port')
if self.port:
Expand Down
5 changes: 4 additions & 1 deletion Notify/pnotify/NotifyBoxcar.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,17 @@ def _notify(self, title, body, notify_type, **kwargs):

url += '/api/push'

self.logger.debug('Boxcar POST URL: %s' % url)
self.logger.debug('Boxcar POST URL: %s (cert_verify=%r)' % (
url, self.verify_certificate,
))
self.logger.debug('Boxcar Payload: %s' % str(payload))
try:
r = requests.post(
url,
data=dumps(payload),
headers=headers,
auth=auth,
verify=self.verify_certificate,
)
if r.status_code != requests.codes.ok:
try:
Expand Down
5 changes: 4 additions & 1 deletion Notify/pnotify/NotifyFaast.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,16 @@ def _notify(self, title, body, notify_type, **kwargs):
if image_url:
payload['icon_url'] = image_url

self.logger.debug('Faast POST URL: %s' % FAAST_URL)
self.logger.debug('Faast POST URL: %s (cert_verify=%r)' % (
FAAST_URL, self.verify_certificate,
))
self.logger.debug('Faast Payload: %s' % str(payload))
try:
r = requests.post(
FAAST_URL,
data=payload,
headers=headers,
verify=self.verify_certificate,
)
if r.status_code != requests.codes.ok:
# We had a problem
Expand Down
5 changes: 4 additions & 1 deletion Notify/pnotify/NotifyJSON.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,17 @@ def _notify(self, title, body, notify_type, **kwargs):

url += self.fullpath

self.logger.debug('JSON POST URL: %s' % url)
self.logger.debug('JSON POST URL: %s (cert_verify=%r)' % (
url, self.verify_certificate,
))
self.logger.debug('JSON Payload: %s' % str(payload))
try:
r = requests.post(
url,
data=dumps(payload),
headers=headers,
auth=auth,
verify=self.verify_certificate,
)
if r.status_code != requests.codes.ok:
try:
Expand Down
5 changes: 4 additions & 1 deletion Notify/pnotify/NotifyJoin.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,17 @@ def _notify(self, title, body, notify_type, **kwargs):
# Prepare the URL
url = '%s?%s' % (JOIN_URL, urlencode(url_args))

self.logger.debug('Join POST URL: %s' % url)
self.logger.debug('Join POST URL: %s (cert_verify=%r)' % (
url, self.verify_certificate,
))
self.logger.debug('Join Payload: %s' % str(payload))

try:
r = requests.post(
url,
data=payload,
headers=headers,
verify=self.verify_certificate,
)
if r.status_code != requests.codes.ok:
# We had a problem
Expand Down
5 changes: 4 additions & 1 deletion Notify/pnotify/NotifyMatterMost.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,16 @@ def _notify(self, title, body, notify_type, **kwargs):

url += '/hooks/%s' % self.authtoken

self.logger.debug('MatterMost POST URL: %s' % url)
self.logger.debug('MatterMost POST URL: %s (cert_verify=%r)' % (
url, self.verify_certificate,
))
self.logger.debug('MatterMost Payload: %s' % str(payload))
try:
r = requests.post(
url,
data=dumps(payload),
headers=headers,
verify=self.verify_certificate,
)
if r.status_code != requests.codes.ok:
# We had a problem
Expand Down
5 changes: 4 additions & 1 deletion Notify/pnotify/NotifyMyAndroid.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,16 @@ def _notify(self, title, body, notify_type, **kwargs):
if self.devapikey:
payload['developerkey'] = self.devapikey

self.logger.debug('NMA POST URL: %s' % NMA_URL)
self.logger.debug('NMA POST URL: %s (cert_verify=%r)' % (
NMA_URL, self.verify_certificate,
))
self.logger.debug('NMA Payload: %s' % str(payload))
try:
r = requests.post(
NMA_URL,
data=payload,
headers=headers,
verify=self.verify_certificate,
)
if r.status_code != requests.codes.ok:
# We had a problem
Expand Down
5 changes: 4 additions & 1 deletion Notify/pnotify/NotifyProwl.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,16 @@ def _notify(self, title, body, **kwargs):
if self.providerkey:
payload['providerkey'] = self.providerkey

self.logger.debug('Prowl POST URL: %s' % PROWL_URL)
self.logger.debug('Prowl POST URL: %s (cert_verify=%r)' % (
PROWL_URL, self.verify_certificate,
))
self.logger.debug('Prowl Payload: %s' % str(payload))
try:
r = requests.post(
PROWL_URL,
data=payload,
headers=headers,
verify=self.verify_certificate,
)
if r.status_code != requests.codes.ok:
# We had a problem
Expand Down
5 changes: 4 additions & 1 deletion Notify/pnotify/NotifyPushBullet.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,17 @@ def _notify(self, title, body, **kwargs):
recipient,
)

self.logger.debug('PushBullet POST URL: %s' % PUSHBULLET_URL)
self.logger.debug('PushBullet POST URL: %s (cert_verify=%r)' % (
PUSHBULLET_URL, self.verify_certificate,
))
self.logger.debug('PushBullet Payload: %s' % str(payload))
try:
r = requests.post(
PUSHBULLET_URL,
data=dumps(payload),
headers=headers,
auth=auth,
verify=self.verify_certificate,
)
if r.status_code != requests.codes.ok:
# We had a problem
Expand Down
5 changes: 4 additions & 1 deletion Notify/pnotify/NotifyPushalot.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,16 @@ def _notify(self, title, body, notify_type, **kwargs):
if image_url:
payload['Image'] = image_url

self.logger.debug('Pushalot POST URL: %s' % PUSHALOT_URL)
self.logger.debug('Pushalot POST URL: %s (cert_verify=%r)' % (
PUSHALOT_URL, self.verify_certificate,
))
self.logger.debug('Pushalot Payload: %s' % str(payload))
try:
r = requests.post(
PUSHALOT_URL,
data=dumps(payload),
headers=headers,
verify=self.verify_certificate,
)
if r.status_code != requests.codes.ok:
# We had a problem
Expand Down
5 changes: 4 additions & 1 deletion Notify/pnotify/NotifyPushover.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,17 @@ def _notify(self, title, body, **kwargs):

payload['device'] = device

self.logger.debug('Pushover POST URL: %s' % PUSHOVER_URL)
self.logger.debug('Pushover POST URL: %s (cert_verify=%r)' % (
PUSHOVER_URL, self.verify_certificate,
))
self.logger.debug('Pushover Payload: %s' % str(payload))
try:
r = requests.post(
PUSHOVER_URL,
data=payload,
headers=headers,
auth=auth,
verify=self.verify_certificate,
)
if r.status_code != requests.codes.ok:
# We had a problem
Expand Down
5 changes: 4 additions & 1 deletion Notify/pnotify/NotifySlack.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,13 +232,16 @@ def _notify(self, title, body, notify_type, **kwargs):
if image_url:
payload['attachments'][0]['footer_icon'] = image_url

self.logger.debug('Slack POST URL: %s' % url)
self.logger.debug('Slack POST URL: %s (cert_verify=%r)' % (
url, self.verify_certificate,
))
self.logger.debug('Slack Payload: %s' % str(payload))
try:
r = requests.post(
url,
data=dumps(payload),
headers=headers,
verify=self.verify_certificate,
)
if r.status_code != requests.codes.ok:
# We had a problem
Expand Down
9 changes: 8 additions & 1 deletion Notify/pnotify/NotifyTelegram.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,9 @@ def _notify(self, title, body, notify_type, **kwargs):
'chat_id': payload['chat_id'],
'disable_notification': True,
}
self.logger.debug('Telegram (image) POST URL: %s' % image_url)
self.logger.debug('Telegram (image) POST URL: %s (cert_verify=%r)' % (
image_url, self.verify_certificate,
))
self.logger.debug('Telegram (image) Payload: %s' % str(image_payload))

try:
Expand All @@ -303,6 +305,7 @@ def _notify(self, title, body, notify_type, **kwargs):
'User-Agent': self.app_id,
},
files=files,
verify=self.verify_certificate,
)
if r.status_code != requests.codes.ok:
# We had a problem
Expand Down Expand Up @@ -352,13 +355,17 @@ def _notify(self, title, body, notify_type, **kwargs):
continue

self.logger.debug('Telegram POST URL: %s' % url)
self.logger.debug('Telegram POST URL: %s (cert_verify=%r)' % (
url, self.verify_certificate,
))
self.logger.debug('Telegram Payload: %s' % str(payload))

try:
r = requests.post(
url,
data=dumps(payload),
headers=headers,
verify=self.verify_certificate,
)
if r.status_code != requests.codes.ok:
# We had a problem
Expand Down
5 changes: 4 additions & 1 deletion Notify/pnotify/NotifyToasty.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,16 @@ def _notify(self, title, body, notify_type, **kwargs):
# URL to transmit content via
url = '%s%s' % (TOASTY_URL, device)

self.logger.debug('Toasty POST URL: %s' % url)
self.logger.debug('Toasty POST URL: %s (cert_verify=%r)' % (
url, self.verify_certificate,
))
self.logger.debug('Toasty Payload: %s' % str(payload))
try:
r = requests.get(
url,
data=payload,
headers=headers,
verify=self.verify_certificate,
)
if r.status_code != requests.codes.ok:
# We had a problem
Expand Down
5 changes: 4 additions & 1 deletion Notify/pnotify/NotifyXBMC.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,17 @@ def _notify(self, title, body, notify_type, **kwargs):

url += '/jsonrpc'

self.logger.debug('XBMC/KODI POST URL: %s' % url)
self.logger.debug('XBMC/KODI POST URL: %s (cert_verify=%r)' % (
url, self.verify_certificate,
))
self.logger.debug('XBMC/KODI Payload: %s' % str(payload))
try:
r = requests.post(
url,
data=payload,
headers=headers,
auth=auth,
verify=self.verify_certificate,
)
if r.status_code != requests.codes.ok:
# We had a problem
Expand Down
5 changes: 4 additions & 1 deletion Notify/pnotify/NotifyXML.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,17 @@ def _notify(self, title, body, notify_type, **kwargs):
url += self.fullpath
payload = re_table.sub(lambda x: re_map[x.group()], self.payload)

self.logger.debug('XML POST URL: %s' % url)
self.logger.debug('XML POST URL: %s (cert_verify=%r)' % (
url, self.verify_certificate,
))
self.logger.debug('XML Payload: %s' % str(payload))
try:
r = requests.post(
url,
data=payload,
headers=headers,
auth=auth,
verify=self.verify_certificate,
)
if r.status_code != requests.codes.ok:
try:
Expand Down

0 comments on commit b15e39f

Please sign in to comment.