Browse Source

docs: Document Python TLS requirements (#12276)

* :wrench: Add simple test script

* :memo: Add documentation

* :wrench: It works, use it

* :wrench: Make the linter happy

* :wrench: Check on bootstrap

* Trivial copyediting

s/operation system/operating system/
Felix Rieseberg 7 years ago
parent
commit
e8735cc005

+ 13 - 0
docs/development/build-instructions-linux.md

@@ -7,6 +7,19 @@ Follow the guidelines below for building Electron on Linux.
 * At least 25GB disk space and 8GB RAM.
 * Python 2.7.x. Some distributions like CentOS 6.x still use Python 2.6.x
   so you may need to check your Python version with `python -V`.
+
+  Please also ensure that your system and Python version support at least TLS 1.2.
+  For a quick test, run the following script:
+
+  ```sh
+  $ python ./script/check-tls.py
+  ```
+
+  If the script returns that your configuration is using an outdated security
+  protocol, use your system's package manager to update Python to the latest
+  version in the 2.7.x branch. Alternatively, visit https://www.python.org/downloads/
+  for detailed instructions.
+
 * Node.js. There are various ways to install Node. You can download
   source code from [nodejs.org](https://nodejs.org) and compile it.
   Doing so permits installing Node on your own home directory as a standard user.

+ 19 - 1
docs/development/build-instructions-osx.md

@@ -7,8 +7,26 @@ Follow the guidelines below for building Electron on macOS.
 * macOS >= 10.11.6
 * [Xcode](https://developer.apple.com/technologies/tools/) >= 8.2.1
 * [node.js](https://nodejs.org) (external)
+* Python 2.7 with support for TLS 1.2
 
-If you are using the Python downloaded by Homebrew, you also need to install
+## Python
+
+Please also ensure that your system and Python version support at least TLS 1.2.
+This depends on both your version of macOS and Python. For a quick test, run:
+
+```sh
+$ python ./script/check-tls.py
+```
+
+If the script returns that your configuration is using an outdated security
+protocol, you can either update macOS to High Sierra or install a new version
+of Python 2.7.x. To upgrade Python, use [Homebrew](https://brew.sh/):
+
+```sh
+$ brew install python@2 && brew link python@2 --force
+```
+
+If you are using Python as provided by Homebrew, you also need to install
 the following Python modules:
 
 * [pyobjc](https://pythonhosted.org/pyobjc/install.html)

+ 3 - 1
script/bootstrap.py

@@ -12,7 +12,7 @@ from lib.config import BASE_URL, PLATFORM, MIPS64EL_SYSROOT_URL, \
                        is_verbose_mode, get_target_arch
 from lib.util import execute, execute_stdout, get_electron_version, \
                      scoped_cwd, download, update_node_modules
-
+from tls import check_tls
 
 SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
 VENDOR_DIR = os.path.join(SOURCE_ROOT, 'vendor')
@@ -31,6 +31,8 @@ def main():
   if sys.platform == 'cygwin':
     update_win32_python()
 
+  check_tls(args.verbose)
+
   update_submodules()
 
   libcc_source_path = args.libcc_source_path

+ 34 - 0
script/tls.py

@@ -0,0 +1,34 @@
+#!/usr/bin/env python
+
+import json
+import urllib2
+import sys
+
+def check_tls(verbose):
+  response = json.load(urllib2.urlopen('https://www.howsmyssl.com/a/check'))
+  tls = response['tls_version']
+
+  if sys.platform == "linux" or sys.platform == "linux2":
+    tutorial = "./docs/development/build-instructions-linux.md"
+  elif sys.platform == "darwin":
+    tutorial = "./docs/development/build-instructions-osx.md"
+  elif sys.platform == "win32":
+    tutorial = "./docs/development/build-instructions-windows.md"
+  else:
+    tutorial = "build instructions for your operating system" \
+      + "in ./docs/development/"
+
+  if tls == "TLS 1.0":
+    print "Your system/python combination is using an outdated security" \
+      + "protocol and will not be able to compile Electron. Please see " \
+      + tutorial + "." \
+      + "for instructions on how to update Python."
+    sys.exit(1)
+  else:
+    if verbose:
+      print "Your Python is using " + tls + ", which is sufficient for" \
+        + "building Electron."
+
+if __name__ == '__main__':
+  check_tls(True)
+  sys.exit(0)