-
-
Notifications
You must be signed in to change notification settings - Fork 34.2k
[2.7] bpo-33570: TLS 1.3 ciphers for OpenSSL 1.1.1 (GH-6976) (GH-8760) #10607
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
Misc/NEWS.d/next/Library/2018-05-18-21-50-47.bpo-33570.7CZy4t.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| Change TLS 1.3 cipher suite settings for compatibility with OpenSSL | ||
| 1.1.1-pre6 and newer. OpenSSL 1.1.1 will have TLS 1.3 cipers enabled by | ||
| default. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -41,15 +41,14 @@ | |||
| log = logging.getLogger("multissl") | ||||
|
|
||||
| OPENSSL_OLD_VERSIONS = [ | ||||
| "0.9.8zc", | ||||
| "0.9.8zh", | ||||
| "1.0.1u", | ||||
| "1.0.2o", | ||||
| ] | ||||
|
|
||||
| OPENSSL_RECENT_VERSIONS = [ | ||||
| "1.0.2", | ||||
| "1.0.2l", | ||||
| "1.1.0f", | ||||
| "1.0.2p", | ||||
| "1.1.0i", | ||||
| # "1.1.1", | ||||
| ] | ||||
|
|
||||
| LIBRESSL_OLD_VERSIONS = [ | ||||
|
|
@@ -59,13 +58,15 @@ | |||
|
|
||||
| LIBRESSL_RECENT_VERSIONS = [ | ||||
| "2.5.5", | ||||
| "2.6.4", | ||||
| "2.7.1", | ||||
| "2.6.5", | ||||
| "2.7.4", | ||||
| ] | ||||
|
|
||||
| # store files in ../multissl | ||||
| HERE = os.path.abspath(os.getcwd()) | ||||
| MULTISSL_DIR = os.path.abspath(os.path.join(HERE, '..', 'multissl')) | ||||
| HERE = os.path.dirname(os.path.abspath(__file__)) | ||||
| PYTHONROOT = os.path.abspath(os.path.join(HERE, '..', '..')) | ||||
| MULTISSL_DIR = os.path.abspath(os.path.join(PYTHONROOT, '..', 'multissl')) | ||||
|
|
||||
|
|
||||
| parser = argparse.ArgumentParser( | ||||
| prog='multissl', | ||||
|
|
@@ -77,7 +78,7 @@ | |||
| parser.add_argument( | ||||
| '--debug', | ||||
| action='store_true', | ||||
| help="Enable debug mode", | ||||
| help="Enable debug logging", | ||||
| ) | ||||
| parser.add_argument( | ||||
| '--disable-ancient', | ||||
|
|
@@ -120,32 +121,49 @@ | |||
| help="Disable network tests." | ||||
| ) | ||||
| parser.add_argument( | ||||
| '--compile-only', | ||||
| action='store_true', | ||||
| help="Don't run tests, only compile _ssl.c and _hashopenssl.c." | ||||
| '--steps', | ||||
| choices=['library', 'modules', 'tests'], | ||||
| default='tests', | ||||
| help=( | ||||
| "Which steps to perform. 'library' downloads and compiles OpenSSL " | ||||
| "or LibreSSL. 'module' also compiles Python modules. 'tests' builds " | ||||
| "all and runs the test suite." | ||||
| ) | ||||
| ) | ||||
|
|
||||
| parser.add_argument( | ||||
| '--force', | ||||
| action='store_true', | ||||
| dest='force', | ||||
| help="Force build and installation." | ||||
| ) | ||||
| parser.add_argument( | ||||
| '--keep-sources', | ||||
| action='store_true', | ||||
| dest='keep_sources', | ||||
| help="Keep original sources for debugging." | ||||
| ) | ||||
|
|
||||
| class AbstractBuilder(object): | ||||
| library = None | ||||
| url_template = None | ||||
| src_template = None | ||||
| build_template = None | ||||
| install_target = 'install' | ||||
|
|
||||
| module_files = ("Modules/_ssl.c", | ||||
| "Modules/_hashopenssl.c") | ||||
| module_libs = ("_ssl", "_hashlib") | ||||
|
|
||||
| def __init__(self, version, compile_args=(), | ||||
| basedir=MULTISSL_DIR): | ||||
| def __init__(self, version, args): | ||||
| self.version = version | ||||
| self.compile_args = compile_args | ||||
| self.args = args | ||||
| # installation directory | ||||
| self.install_dir = os.path.join( | ||||
| os.path.join(basedir, self.library.lower()), version | ||||
| os.path.join(args.base_directory, self.library.lower()), version | ||||
| ) | ||||
| # source file | ||||
| self.src_dir = os.path.join(basedir, 'src') | ||||
| self.src_dir = os.path.join(args.base_directory, 'src') | ||||
| self.src_file = os.path.join( | ||||
| self.src_dir, self.src_template.format(version)) | ||||
| # build directory (removed after install) | ||||
|
|
@@ -252,21 +270,29 @@ def _unpack_src(self): | |||
| def _build_src(self): | ||||
| """Now build openssl""" | ||||
| log.info("Running build in {}".format(self.build_dir)) | ||||
| cwd = self.build_dir | ||||
| cmd = ["./config", "shared", "--prefix={}".format(self.install_dir)] | ||||
| cmd.extend(self.compile_args) | ||||
| cmd = [ | ||||
| "./config", | ||||
| "shared", "--debug", | ||||
| "--prefix={}".format(self.install_dir) | ||||
| ] | ||||
| env = os.environ.copy() | ||||
| # set rpath | ||||
| env["LD_RUN_PATH"] = self.lib_dir | ||||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here cpython/Tools/ssl/multissltests.py Line 283 in 9fb051f
|
||||
| self._subprocess_call(cmd, cwd=cwd) | ||||
| # Old OpenSSL versions do not support parallel builds. | ||||
| self._subprocess_call(["make", "-j1"], cwd=cwd) | ||||
|
|
||||
| def _make_install(self, remove=True): | ||||
| self._subprocess_call(["make", "-j1", "install"], cwd=self.build_dir) | ||||
| if remove: | ||||
| def _make_install(self): | ||||
| self._subprocess_call( | ||||
| ["make", "-j1", self.install_target], | ||||
| cwd=self.build_dir | ||||
| ) | ||||
| if not self.args.keep_sources: | ||||
| shutil.rmtree(self.build_dir) | ||||
|
|
||||
| def install(self): | ||||
| log.info(self.openssl_cli) | ||||
| if not self.has_openssl: | ||||
| if not self.has_openssl or self.args.force: | ||||
| if not self.has_src: | ||||
| self._download_src() | ||||
| else: | ||||
|
|
@@ -332,6 +358,8 @@ class BuildOpenSSL(AbstractBuilder): | |||
| url_template = "https://www.openssl.org/source/openssl-{}.tar.gz" | ||||
| src_template = "openssl-{}.tar.gz" | ||||
| build_template = "openssl-{}" | ||||
| # only install software, skip docs | ||||
| install_target = 'install_sw' | ||||
|
|
||||
|
|
||||
| class BuildLibreSSL(AbstractBuilder): | ||||
|
|
@@ -370,57 +398,64 @@ def main(): | |||
|
|
||||
| start = datetime.now() | ||||
|
|
||||
| for name in ['python', 'setup.py', 'Modules/_ssl.c']: | ||||
| if not os.path.isfile(name): | ||||
| if args.steps in {'modules', 'tests'}: | ||||
| for name in ['setup.py', 'Modules/_ssl.c']: | ||||
| if not os.path.isfile(os.path.join(PYTHONROOT, name)): | ||||
| parser.error( | ||||
| "Must be executed with ./python from CPython build dir" | ||||
| ) | ||||
| if not os.path.samefile('python', sys.executable): | ||||
| parser.error( | ||||
| "Must be executed from CPython build dir" | ||||
| ) | ||||
| if not os.path.samefile('python', sys.executable): | ||||
| parser.error( | ||||
| "Must be executed with ./python from CPython build dir" | ||||
| ) | ||||
|
|
||||
| # check for configure and run make | ||||
| configure_make() | ||||
| # check for configure and run make | ||||
| configure_make() | ||||
|
|
||||
| # download and register builder | ||||
| builds = [] | ||||
|
|
||||
| for version in args.openssl: | ||||
| build = BuildOpenSSL(version) | ||||
| build = BuildOpenSSL( | ||||
| version, | ||||
| args | ||||
| ) | ||||
| build.install() | ||||
| builds.append(build) | ||||
|
|
||||
| for version in args.libressl: | ||||
| build = BuildLibreSSL(version) | ||||
| build = BuildLibreSSL( | ||||
| version, | ||||
| args | ||||
| ) | ||||
| build.install() | ||||
| builds.append(build) | ||||
|
|
||||
| for build in builds: | ||||
| try: | ||||
| build.recompile_pymods() | ||||
| build.check_pyssl() | ||||
| if not args.compile_only: | ||||
| build.run_python_tests( | ||||
| tests=args.tests, | ||||
| network=args.network, | ||||
| ) | ||||
| except Exception as e: | ||||
| log.exception("%s failed", build) | ||||
| print("{} failed: {}".format(build, e), file=sys.stderr) | ||||
| sys.exit(2) | ||||
|
|
||||
| print("\n{} finished in {}".format( | ||||
| "Tests" if not args.compile_only else "Builds", | ||||
| datetime.now() - start | ||||
| )) | ||||
| if args.steps in {'modules', 'tests'}: | ||||
| for build in builds: | ||||
| try: | ||||
| build.recompile_pymods() | ||||
| build.check_pyssl() | ||||
| if args.steps == 'tests': | ||||
| build.run_python_tests( | ||||
| tests=args.tests, | ||||
| network=args.network, | ||||
| ) | ||||
| except Exception as e: | ||||
| log.exception("%s failed", build) | ||||
| print("{} failed: {}".format(build, e), file=sys.stderr) | ||||
| sys.exit(2) | ||||
|
|
||||
| log.info("\n{} finished in {}".format( | ||||
| args.steps.capitalize(), | ||||
| datetime.now() - start | ||||
| )) | ||||
| print('Python: ', sys.version) | ||||
| if args.compile_only: | ||||
| print('Build only') | ||||
| elif args.tests: | ||||
| print('Executed Tests:', ' '.join(args.tests)) | ||||
| else: | ||||
| print('Executed all SSL tests.') | ||||
| if args.steps == 'tests': | ||||
| if args.tests: | ||||
| print('Executed Tests:', ' '.join(args.tests)) | ||||
| else: | ||||
| print('Executed all SSL tests.') | ||||
|
|
||||
| print('OpenSSL / LibreSSL versions:') | ||||
| for build in builds: | ||||
|
|
||||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it skipped on purpose?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, with this PR, python2 is not yet completely compatible with openssl 1.1.1, it will be with the follow-up PR's.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. I preferred to ask.