Skip to content

Commit

Permalink
Merge pull request #32 from ChrisTruncer/ssl_patch
Browse files Browse the repository at this point in the history
Patch to work on newer python versions which validate ssl
  • Loading branch information
ChrisTruncer committed Sep 13, 2015
2 parents d3b921f + 3e83fa2 commit 5bd5cb4
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions protocols/clients/https_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
'''

import ssl
import sys
import urllib2

Expand All @@ -23,6 +24,15 @@ def __init__(self, cli_object):
self.file_transfer = cli_object.file

def transmit(self, data_to_transmit):
# This restores the same behavior as before.
try:
_create_unverified_https_context = ssl._create_unverified_context
except AttributeError:
# Legacy Python that doesn't verify HTTPS certificates by default
pass
else:
# Handle target environment that doesn't support HTTPS verification
ssl._create_default_https_context = _create_unverified_https_context
if not self.file_transfer:
url = "https://" + self.remote_server + "/post_data.php"

Expand Down

0 comments on commit 5bd5cb4

Please sign in to comment.