Skip to content

Instantly share code, notes, and snippets.

@miigotu
Last active August 29, 2015 14:20
Show Gist options
  • Select an option

  • Save miigotu/6636357fe3e7069e2a02 to your computer and use it in GitHub Desktop.

Select an option

Save miigotu/6636357fe3e7069e2a02 to your computer and use it in GitHub Desktop.
Check for SSL errors and correct dependancies.
#!/bin/bash
#Install our required modules, with the correct versions.
/usr/bin/env pip2.7 install -q -U 'cheetah>=2.1.0' 'pyopenssl<=0.13.1' 'requests<=2.6.0' 'ndg-httpsclient' 'pyasn1'
#Test out the environment, and try to access a site on shared hosting needing SNI
/usr/bin/env python2 <<PYDOC
import sys
try:
import OpenSSL
from OpenSSL.version import __version__ as pyOpenSSL_Version
print('pyOpenSSL Version: ' + pyOpenSSL_Version)
if int(pyOpenSSL_Version.replace('.', '')[:3]) > 13:
print('OpenSSL is 0.14 or newer, checking for cryptography')
import cryptography
except Exception as e:
print(e)
raise
sys.exit(1)
try:
import requests
import ndg.httpsclient
import pyasn1
except Exception as e:
print(e)
raise
sys.exit(1)
try:
from requests.packages.urllib3.contrib.pyopenssl import inject_into_urllib3
from requests.packages.urllib3 import disable_warnings
except Exception as e:
print(e)
raise
sys.exit(1)
try:
disable_warnings()
inject_into_urllib3()
except Exception as e:
print(e)
raise
sys.exit(1)
try:
req = requests.get("https://sceneaccess.eu")
assert req.status_code == 200
except Exception as e:
print(e)
raise
sys.exit(1)
finally:
print('Success!')
sys.exit(0)
PYDOC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment