Skip to content

Commit

Permalink
Added check to see if the python interpreter supports TLS v1.2, and
Browse files Browse the repository at this point in the history
added error message explaining the situation to be displayed if it doesnt
  • Loading branch information
theJenix committed Jan 27, 2016
1 parent 3ea7883 commit 227b14a
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions diawi-cli
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import random
import string
import urllib
import urllib2
import sys

handler=urllib2.HTTPHandler(debuglevel=1)
opener = urllib2.build_opener(handler)
Expand All @@ -23,6 +24,14 @@ from httplib import HTTPConnection, HTTPS_PORT
import ssl
import socket

def is_supported_version():
try:
ssl.PROTOCOL_TLSv1_2
except AttributeError:
return False
else:
return True

class HTTPSConnection(HTTPConnection):
"This class allows communication via SSL."
default_port = HTTPS_PORT
Expand Down Expand Up @@ -74,6 +83,12 @@ def response_to_json(response):

return json.loads(responseStr)

if not is_supported_version():
print "ERROR: This script requires a Python interpreter with TLS v1.2 support, which was added in Python 2.7.9. Please \
upgrade your Python interpreter, or recompile with TLS v1.2 support. Note that version of Python shipped with Mac OS \
X El Capitan is nominally 2.7.10, but is missing TLS v1.2 support. Exiting."
exit(1)

parser = argparse.ArgumentParser()
parser.add_argument("filename", help="The .ipa file to deploy.")
parser.add_argument("-c", "--comment", help="Comment to display to the installer")
Expand Down

0 comments on commit 227b14a

Please sign in to comment.