tls.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/usr/bin/env python
  2. import json
  3. import os
  4. import ssl
  5. import subprocess
  6. import sys
  7. import urllib2
  8. ctx = ssl.create_default_context()
  9. ctx.check_hostname = False
  10. ctx.verify_mode = ssl.CERT_NONE
  11. def check_tls(verbose):
  12. process = subprocess.Popen(
  13. 'node tls.js',
  14. cwd=os.path.dirname(os.path.realpath(__file__)),
  15. shell=True,
  16. stdout=subprocess.PIPE,
  17. stderr=subprocess.STDOUT
  18. )
  19. port = process.stdout.readline()
  20. localhost_url = 'https://localhost:' + port
  21. response = json.load(urllib2.urlopen(localhost_url, context=ctx))
  22. tls = response['protocol']
  23. process.wait()
  24. if sys.platform == "linux" or sys.platform == "linux2":
  25. tutorial = "./docs/development/build-instructions-linux.md"
  26. elif sys.platform == "darwin":
  27. tutorial = "./docs/development/build-instructions-osx.md"
  28. elif sys.platform == "win32":
  29. tutorial = "./docs/development/build-instructions-windows.md"
  30. else:
  31. tutorial = "build instructions for your operating system" \
  32. + "in ./docs/development/"
  33. if tls == "TLSv1" or tls == "TLSv1.1":
  34. print "Your system/python combination is using an outdated security" \
  35. + "protocol and will not be able to compile Electron. Please see " \
  36. + tutorial + "." \
  37. + "for instructions on how to update Python."
  38. sys.exit(1)
  39. else:
  40. if verbose:
  41. print "Your Python is using " + tls + ", which is sufficient for " \
  42. + "building Electron."
  43. if __name__ == '__main__':
  44. check_tls(True)
  45. sys.exit(0)