We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Make OpenSSL 1.0.2 error (+ env var fallback)


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `src/cryptography/hazmat/bindings/openssl/binding.py`
Content:
```
1 # This file is dual licensed under the terms of the Apache License, Version
2 # 2.0, and the BSD License. See the LICENSE file in the root of this repository
3 # for complete details.
4 
5 from __future__ import absolute_import, division, print_function
6 
7 import collections
8 import threading
9 import types
10 import warnings
11 
12 import cryptography
13 from cryptography import utils
14 from cryptography.exceptions import InternalError
15 from cryptography.hazmat.bindings._openssl import ffi, lib
16 from cryptography.hazmat.bindings.openssl._conditional import CONDITIONAL_NAMES
17 
18 _OpenSSLErrorWithText = collections.namedtuple(
19     "_OpenSSLErrorWithText", ["code", "lib", "func", "reason", "reason_text"]
20 )
21 
22 
23 class _OpenSSLError(object):
24     def __init__(self, code, lib, func, reason):
25         self._code = code
26         self._lib = lib
27         self._func = func
28         self._reason = reason
29 
30     def _lib_reason_match(self, lib, reason):
31         return lib == self.lib and reason == self.reason
32 
33     code = utils.read_only_property("_code")
34     lib = utils.read_only_property("_lib")
35     func = utils.read_only_property("_func")
36     reason = utils.read_only_property("_reason")
37 
38 
39 def _consume_errors(lib):
40     errors = []
41     while True:
42         code = lib.ERR_get_error()
43         if code == 0:
44             break
45 
46         err_lib = lib.ERR_GET_LIB(code)
47         err_func = lib.ERR_GET_FUNC(code)
48         err_reason = lib.ERR_GET_REASON(code)
49 
50         errors.append(_OpenSSLError(code, err_lib, err_func, err_reason))
51 
52     return errors
53 
54 
55 def _errors_with_text(errors):
56     errors_with_text = []
57     for err in errors:
58         buf = ffi.new("char[]", 256)
59         lib.ERR_error_string_n(err.code, buf, len(buf))
60         err_text_reason = ffi.string(buf)
61 
62         errors_with_text.append(
63             _OpenSSLErrorWithText(
64                 err.code, err.lib, err.func, err.reason, err_text_reason
65             )
66         )
67 
68     return errors_with_text
69 
70 
71 def _consume_errors_with_text(lib):
72     return _errors_with_text(_consume_errors(lib))
73 
74 
75 def _openssl_assert(lib, ok, errors=None):
76     if not ok:
77         if errors is None:
78             errors = _consume_errors(lib)
79         errors_with_text = _errors_with_text(errors)
80 
81         raise InternalError(
82             "Unknown OpenSSL error. This error is commonly encountered when "
83             "another library is not cleaning up the OpenSSL error stack. If "
84             "you are using cryptography with another library that uses "
85             "OpenSSL try disabling it before reporting a bug. Otherwise "
86             "please file an issue at https://github.com/pyca/cryptography/"
87             "issues with information on how to reproduce "
88             "this. ({0!r})".format(errors_with_text),
89             errors_with_text,
90         )
91 
92 
93 def build_conditional_library(lib, conditional_names):
94     conditional_lib = types.ModuleType("lib")
95     conditional_lib._original_lib = lib
96     excluded_names = set()
97     for condition, names_cb in conditional_names.items():
98         if not getattr(lib, condition):
99             excluded_names.update(names_cb())
100 
101     for attr in dir(lib):
102         if attr not in excluded_names:
103             setattr(conditional_lib, attr, getattr(lib, attr))
104 
105     return conditional_lib
106 
107 
108 class Binding(object):
109     """
110     OpenSSL API wrapper.
111     """
112 
113     lib = None
114     ffi = ffi
115     _lib_loaded = False
116     _init_lock = threading.Lock()
117     _lock_init_lock = threading.Lock()
118 
119     def __init__(self):
120         self._ensure_ffi_initialized()
121 
122     @classmethod
123     def _register_osrandom_engine(cls):
124         # Clear any errors extant in the queue before we start. In many
125         # scenarios other things may be interacting with OpenSSL in the same
126         # process space and it has proven untenable to assume that they will
127         # reliably clear the error queue. Once we clear it here we will
128         # error on any subsequent unexpected item in the stack.
129         cls.lib.ERR_clear_error()
130         if cls.lib.CRYPTOGRAPHY_NEEDS_OSRANDOM_ENGINE:
131             result = cls.lib.Cryptography_add_osrandom_engine()
132             _openssl_assert(cls.lib, result in (1, 2))
133 
134     @classmethod
135     def _ensure_ffi_initialized(cls):
136         with cls._init_lock:
137             if not cls._lib_loaded:
138                 cls.lib = build_conditional_library(lib, CONDITIONAL_NAMES)
139                 cls._lib_loaded = True
140                 # initialize the SSL library
141                 cls.lib.SSL_library_init()
142                 # adds all ciphers/digests for EVP
143                 cls.lib.OpenSSL_add_all_algorithms()
144                 # loads error strings for libcrypto and libssl functions
145                 cls.lib.SSL_load_error_strings()
146                 cls._register_osrandom_engine()
147 
148     @classmethod
149     def init_static_locks(cls):
150         with cls._lock_init_lock:
151             cls._ensure_ffi_initialized()
152             # Use Python's implementation if available, importing _ssl triggers
153             # the setup for this.
154             __import__("_ssl")
155 
156             if (
157                 not cls.lib.Cryptography_HAS_LOCKING_CALLBACKS
158                 or cls.lib.CRYPTO_get_locking_callback() != cls.ffi.NULL
159             ):
160                 return
161 
162             # If nothing else has setup a locking callback already, we set up
163             # our own
164             res = lib.Cryptography_setup_ssl_threads()
165             _openssl_assert(cls.lib, res == 1)
166 
167 
168 def _verify_openssl_version(lib):
169     if (
170         lib.CRYPTOGRAPHY_OPENSSL_LESS_THAN_110
171         and not lib.CRYPTOGRAPHY_IS_LIBRESSL
172     ):
173         warnings.warn(
174             "OpenSSL version 1.0.2 is no longer supported by the OpenSSL "
175             "project, please upgrade. The next version of cryptography will "
176             "drop support for it.",
177             utils.CryptographyDeprecationWarning,
178         )
179 
180 
181 def _verify_package_version(version):
182     # Occasionally we run into situations where the version of the Python
183     # package does not match the version of the shared object that is loaded.
184     # This may occur in environments where multiple versions of cryptography
185     # are installed and available in the python path. To avoid errors cropping
186     # up later this code checks that the currently imported package and the
187     # shared object that were loaded have the same version and raise an
188     # ImportError if they do not
189     so_package_version = ffi.string(lib.CRYPTOGRAPHY_PACKAGE_VERSION)
190     if version.encode("ascii") != so_package_version:
191         raise ImportError(
192             "The version of cryptography does not match the loaded "
193             "shared object. This can happen if you have multiple copies of "
194             "cryptography installed in your Python path. Please try creating "
195             "a new virtual environment to resolve this issue. "
196             "Loaded python version: {}, shared object version: {}".format(
197                 version, so_package_version
198             )
199         )
200 
201 
202 _verify_package_version(cryptography.__version__)
203 
204 # OpenSSL is not thread safe until the locks are initialized. We call this
205 # method in module scope so that it executes with the import lock. On
206 # Pythons < 3.4 this import lock is a global lock, which can prevent a race
207 # condition registering the OpenSSL locks. On Python 3.4+ the import lock
208 # is per module so this approach will not work.
209 Binding.init_static_locks()
210 
211 _verify_openssl_version(Binding.lib)
212
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/src/cryptography/hazmat/bindings/openssl/binding.py b/src/cryptography/hazmat/bindings/openssl/binding.py
--- a/src/cryptography/hazmat/bindings/openssl/binding.py
+++ b/src/cryptography/hazmat/bindings/openssl/binding.py
@@ -5,6 +5,7 @@
 from __future__ import absolute_import, division, print_function
 
 import collections
+import os
 import threading
 import types
 import warnings
@@ -170,12 +171,19 @@
         lib.CRYPTOGRAPHY_OPENSSL_LESS_THAN_110
         and not lib.CRYPTOGRAPHY_IS_LIBRESSL
     ):
-        warnings.warn(
-            "OpenSSL version 1.0.2 is no longer supported by the OpenSSL "
-            "project, please upgrade. The next version of cryptography will "
-            "drop support for it.",
-            utils.CryptographyDeprecationWarning,
-        )
+        if os.environ.get("CRYPTOGRAPHY_ALLOW_OPENSSL_102"):
+            warnings.warn(
+                "OpenSSL version 1.0.2 is no longer supported by the OpenSSL "
+                "project, please upgrade. The next version of cryptography "
+                "will completely remove support for it.",
+                utils.CryptographyDeprecationWarning,
+            )
+        else:
+            raise RuntimeError(
+                "You are linking against OpenSSL 1.0.2, which is no longer "
+                "supported by the OpenSSL project. You need to upgrade to a "
+                "newer version of OpenSSL."
+            )
 
 
 def _verify_package_version(version):

{"golden_diff": "diff --git a/src/cryptography/hazmat/bindings/openssl/binding.py b/src/cryptography/hazmat/bindings/openssl/binding.py\n--- a/src/cryptography/hazmat/bindings/openssl/binding.py\n+++ b/src/cryptography/hazmat/bindings/openssl/binding.py\n@@ -5,6 +5,7 @@\n from __future__ import absolute_import, division, print_function\n \n import collections\n+import os\n import threading\n import types\n import warnings\n@@ -170,12 +171,19 @@\n         lib.CRYPTOGRAPHY_OPENSSL_LESS_THAN_110\n         and not lib.CRYPTOGRAPHY_IS_LIBRESSL\n     ):\n-        warnings.warn(\n-            \"OpenSSL version 1.0.2 is no longer supported by the OpenSSL \"\n-            \"project, please upgrade. The next version of cryptography will \"\n-            \"drop support for it.\",\n-            utils.CryptographyDeprecationWarning,\n-        )\n+        if os.environ.get(\"CRYPTOGRAPHY_ALLOW_OPENSSL_102\"):\n+            warnings.warn(\n+                \"OpenSSL version 1.0.2 is no longer supported by the OpenSSL \"\n+                \"project, please upgrade. The next version of cryptography \"\n+                \"will completely remove support for it.\",\n+                utils.CryptographyDeprecationWarning,\n+            )\n+        else:\n+            raise RuntimeError(\n+                \"You are linking against OpenSSL 1.0.2, which is no longer \"\n+                \"supported by the OpenSSL project. You need to upgrade to a \"\n+                \"newer version of OpenSSL.\"\n+            )\n \n \n def _verify_package_version(version):\n", "issue": "Make OpenSSL 1.0.2 error (+ env var fallback)\n\n", "before_files": [{"content": "# This file is dual licensed under the terms of the Apache License, Version\n# 2.0, and the BSD License. See the LICENSE file in the root of this repository\n# for complete details.\n\nfrom __future__ import absolute_import, division, print_function\n\nimport collections\nimport threading\nimport types\nimport warnings\n\nimport cryptography\nfrom cryptography import utils\nfrom cryptography.exceptions import InternalError\nfrom cryptography.hazmat.bindings._openssl import ffi, lib\nfrom cryptography.hazmat.bindings.openssl._conditional import CONDITIONAL_NAMES\n\n_OpenSSLErrorWithText = collections.namedtuple(\n    \"_OpenSSLErrorWithText\", [\"code\", \"lib\", \"func\", \"reason\", \"reason_text\"]\n)\n\n\nclass _OpenSSLError(object):\n    def __init__(self, code, lib, func, reason):\n        self._code = code\n        self._lib = lib\n        self._func = func\n        self._reason = reason\n\n    def _lib_reason_match(self, lib, reason):\n        return lib == self.lib and reason == self.reason\n\n    code = utils.read_only_property(\"_code\")\n    lib = utils.read_only_property(\"_lib\")\n    func = utils.read_only_property(\"_func\")\n    reason = utils.read_only_property(\"_reason\")\n\n\ndef _consume_errors(lib):\n    errors = []\n    while True:\n        code = lib.ERR_get_error()\n        if code == 0:\n            break\n\n        err_lib = lib.ERR_GET_LIB(code)\n        err_func = lib.ERR_GET_FUNC(code)\n        err_reason = lib.ERR_GET_REASON(code)\n\n        errors.append(_OpenSSLError(code, err_lib, err_func, err_reason))\n\n    return errors\n\n\ndef _errors_with_text(errors):\n    errors_with_text = []\n    for err in errors:\n        buf = ffi.new(\"char[]\", 256)\n        lib.ERR_error_string_n(err.code, buf, len(buf))\n        err_text_reason = ffi.string(buf)\n\n        errors_with_text.append(\n            _OpenSSLErrorWithText(\n                err.code, err.lib, err.func, err.reason, err_text_reason\n            )\n        )\n\n    return errors_with_text\n\n\ndef _consume_errors_with_text(lib):\n    return _errors_with_text(_consume_errors(lib))\n\n\ndef _openssl_assert(lib, ok, errors=None):\n    if not ok:\n        if errors is None:\n            errors = _consume_errors(lib)\n        errors_with_text = _errors_with_text(errors)\n\n        raise InternalError(\n            \"Unknown OpenSSL error. This error is commonly encountered when \"\n            \"another library is not cleaning up the OpenSSL error stack. If \"\n            \"you are using cryptography with another library that uses \"\n            \"OpenSSL try disabling it before reporting a bug. Otherwise \"\n            \"please file an issue at https://github.com/pyca/cryptography/\"\n            \"issues with information on how to reproduce \"\n            \"this. ({0!r})\".format(errors_with_text),\n            errors_with_text,\n        )\n\n\ndef build_conditional_library(lib, conditional_names):\n    conditional_lib = types.ModuleType(\"lib\")\n    conditional_lib._original_lib = lib\n    excluded_names = set()\n    for condition, names_cb in conditional_names.items():\n        if not getattr(lib, condition):\n            excluded_names.update(names_cb())\n\n    for attr in dir(lib):\n        if attr not in excluded_names:\n            setattr(conditional_lib, attr, getattr(lib, attr))\n\n    return conditional_lib\n\n\nclass Binding(object):\n    \"\"\"\n    OpenSSL API wrapper.\n    \"\"\"\n\n    lib = None\n    ffi = ffi\n    _lib_loaded = False\n    _init_lock = threading.Lock()\n    _lock_init_lock = threading.Lock()\n\n    def __init__(self):\n        self._ensure_ffi_initialized()\n\n    @classmethod\n    def _register_osrandom_engine(cls):\n        # Clear any errors extant in the queue before we start. In many\n        # scenarios other things may be interacting with OpenSSL in the same\n        # process space and it has proven untenable to assume that they will\n        # reliably clear the error queue. Once we clear it here we will\n        # error on any subsequent unexpected item in the stack.\n        cls.lib.ERR_clear_error()\n        if cls.lib.CRYPTOGRAPHY_NEEDS_OSRANDOM_ENGINE:\n            result = cls.lib.Cryptography_add_osrandom_engine()\n            _openssl_assert(cls.lib, result in (1, 2))\n\n    @classmethod\n    def _ensure_ffi_initialized(cls):\n        with cls._init_lock:\n            if not cls._lib_loaded:\n                cls.lib = build_conditional_library(lib, CONDITIONAL_NAMES)\n                cls._lib_loaded = True\n                # initialize the SSL library\n                cls.lib.SSL_library_init()\n                # adds all ciphers/digests for EVP\n                cls.lib.OpenSSL_add_all_algorithms()\n                # loads error strings for libcrypto and libssl functions\n                cls.lib.SSL_load_error_strings()\n                cls._register_osrandom_engine()\n\n    @classmethod\n    def init_static_locks(cls):\n        with cls._lock_init_lock:\n            cls._ensure_ffi_initialized()\n            # Use Python's implementation if available, importing _ssl triggers\n            # the setup for this.\n            __import__(\"_ssl\")\n\n            if (\n                not cls.lib.Cryptography_HAS_LOCKING_CALLBACKS\n                or cls.lib.CRYPTO_get_locking_callback() != cls.ffi.NULL\n            ):\n                return\n\n            # If nothing else has setup a locking callback already, we set up\n            # our own\n            res = lib.Cryptography_setup_ssl_threads()\n            _openssl_assert(cls.lib, res == 1)\n\n\ndef _verify_openssl_version(lib):\n    if (\n        lib.CRYPTOGRAPHY_OPENSSL_LESS_THAN_110\n        and not lib.CRYPTOGRAPHY_IS_LIBRESSL\n    ):\n        warnings.warn(\n            \"OpenSSL version 1.0.2 is no longer supported by the OpenSSL \"\n            \"project, please upgrade. The next version of cryptography will \"\n            \"drop support for it.\",\n            utils.CryptographyDeprecationWarning,\n        )\n\n\ndef _verify_package_version(version):\n    # Occasionally we run into situations where the version of the Python\n    # package does not match the version of the shared object that is loaded.\n    # This may occur in environments where multiple versions of cryptography\n    # are installed and available in the python path. To avoid errors cropping\n    # up later this code checks that the currently imported package and the\n    # shared object that were loaded have the same version and raise an\n    # ImportError if they do not\n    so_package_version = ffi.string(lib.CRYPTOGRAPHY_PACKAGE_VERSION)\n    if version.encode(\"ascii\") != so_package_version:\n        raise ImportError(\n            \"The version of cryptography does not match the loaded \"\n            \"shared object. This can happen if you have multiple copies of \"\n            \"cryptography installed in your Python path. Please try creating \"\n            \"a new virtual environment to resolve this issue. \"\n            \"Loaded python version: {}, shared object version: {}\".format(\n                version, so_package_version\n            )\n        )\n\n\n_verify_package_version(cryptography.__version__)\n\n# OpenSSL is not thread safe until the locks are initialized. We call this\n# method in module scope so that it executes with the import lock. On\n# Pythons < 3.4 this import lock is a global lock, which can prevent a race\n# condition registering the OpenSSL locks. On Python 3.4+ the import lock\n# is per module so this approach will not work.\nBinding.init_static_locks()\n\n_verify_openssl_version(Binding.lib)\n", "path": "src/cryptography/hazmat/bindings/openssl/binding.py"}], "after_files": [{"content": "# This file is dual licensed under the terms of the Apache License, Version\n# 2.0, and the BSD License. See the LICENSE file in the root of this repository\n# for complete details.\n\nfrom __future__ import absolute_import, division, print_function\n\nimport collections\nimport os\nimport threading\nimport types\nimport warnings\n\nimport cryptography\nfrom cryptography import utils\nfrom cryptography.exceptions import InternalError\nfrom cryptography.hazmat.bindings._openssl import ffi, lib\nfrom cryptography.hazmat.bindings.openssl._conditional import CONDITIONAL_NAMES\n\n_OpenSSLErrorWithText = collections.namedtuple(\n    \"_OpenSSLErrorWithText\", [\"code\", \"lib\", \"func\", \"reason\", \"reason_text\"]\n)\n\n\nclass _OpenSSLError(object):\n    def __init__(self, code, lib, func, reason):\n        self._code = code\n        self._lib = lib\n        self._func = func\n        self._reason = reason\n\n    def _lib_reason_match(self, lib, reason):\n        return lib == self.lib and reason == self.reason\n\n    code = utils.read_only_property(\"_code\")\n    lib = utils.read_only_property(\"_lib\")\n    func = utils.read_only_property(\"_func\")\n    reason = utils.read_only_property(\"_reason\")\n\n\ndef _consume_errors(lib):\n    errors = []\n    while True:\n        code = lib.ERR_get_error()\n        if code == 0:\n            break\n\n        err_lib = lib.ERR_GET_LIB(code)\n        err_func = lib.ERR_GET_FUNC(code)\n        err_reason = lib.ERR_GET_REASON(code)\n\n        errors.append(_OpenSSLError(code, err_lib, err_func, err_reason))\n\n    return errors\n\n\ndef _errors_with_text(errors):\n    errors_with_text = []\n    for err in errors:\n        buf = ffi.new(\"char[]\", 256)\n        lib.ERR_error_string_n(err.code, buf, len(buf))\n        err_text_reason = ffi.string(buf)\n\n        errors_with_text.append(\n            _OpenSSLErrorWithText(\n                err.code, err.lib, err.func, err.reason, err_text_reason\n            )\n        )\n\n    return errors_with_text\n\n\ndef _consume_errors_with_text(lib):\n    return _errors_with_text(_consume_errors(lib))\n\n\ndef _openssl_assert(lib, ok, errors=None):\n    if not ok:\n        if errors is None:\n            errors = _consume_errors(lib)\n        errors_with_text = _errors_with_text(errors)\n\n        raise InternalError(\n            \"Unknown OpenSSL error. This error is commonly encountered when \"\n            \"another library is not cleaning up the OpenSSL error stack. If \"\n            \"you are using cryptography with another library that uses \"\n            \"OpenSSL try disabling it before reporting a bug. Otherwise \"\n            \"please file an issue at https://github.com/pyca/cryptography/\"\n            \"issues with information on how to reproduce \"\n            \"this. ({0!r})\".format(errors_with_text),\n            errors_with_text,\n        )\n\n\ndef build_conditional_library(lib, conditional_names):\n    conditional_lib = types.ModuleType(\"lib\")\n    conditional_lib._original_lib = lib\n    excluded_names = set()\n    for condition, names_cb in conditional_names.items():\n        if not getattr(lib, condition):\n            excluded_names.update(names_cb())\n\n    for attr in dir(lib):\n        if attr not in excluded_names:\n            setattr(conditional_lib, attr, getattr(lib, attr))\n\n    return conditional_lib\n\n\nclass Binding(object):\n    \"\"\"\n    OpenSSL API wrapper.\n    \"\"\"\n\n    lib = None\n    ffi = ffi\n    _lib_loaded = False\n    _init_lock = threading.Lock()\n    _lock_init_lock = threading.Lock()\n\n    def __init__(self):\n        self._ensure_ffi_initialized()\n\n    @classmethod\n    def _register_osrandom_engine(cls):\n        # Clear any errors extant in the queue before we start. In many\n        # scenarios other things may be interacting with OpenSSL in the same\n        # process space and it has proven untenable to assume that they will\n        # reliably clear the error queue. Once we clear it here we will\n        # error on any subsequent unexpected item in the stack.\n        cls.lib.ERR_clear_error()\n        if cls.lib.CRYPTOGRAPHY_NEEDS_OSRANDOM_ENGINE:\n            result = cls.lib.Cryptography_add_osrandom_engine()\n            _openssl_assert(cls.lib, result in (1, 2))\n\n    @classmethod\n    def _ensure_ffi_initialized(cls):\n        with cls._init_lock:\n            if not cls._lib_loaded:\n                cls.lib = build_conditional_library(lib, CONDITIONAL_NAMES)\n                cls._lib_loaded = True\n                # initialize the SSL library\n                cls.lib.SSL_library_init()\n                # adds all ciphers/digests for EVP\n                cls.lib.OpenSSL_add_all_algorithms()\n                # loads error strings for libcrypto and libssl functions\n                cls.lib.SSL_load_error_strings()\n                cls._register_osrandom_engine()\n\n    @classmethod\n    def init_static_locks(cls):\n        with cls._lock_init_lock:\n            cls._ensure_ffi_initialized()\n            # Use Python's implementation if available, importing _ssl triggers\n            # the setup for this.\n            __import__(\"_ssl\")\n\n            if (\n                not cls.lib.Cryptography_HAS_LOCKING_CALLBACKS\n                or cls.lib.CRYPTO_get_locking_callback() != cls.ffi.NULL\n            ):\n                return\n\n            # If nothing else has setup a locking callback already, we set up\n            # our own\n            res = lib.Cryptography_setup_ssl_threads()\n            _openssl_assert(cls.lib, res == 1)\n\n\ndef _verify_openssl_version(lib):\n    if (\n        lib.CRYPTOGRAPHY_OPENSSL_LESS_THAN_110\n        and not lib.CRYPTOGRAPHY_IS_LIBRESSL\n    ):\n        if os.environ.get(\"CRYPTOGRAPHY_ALLOW_OPENSSL_102\"):\n            warnings.warn(\n                \"OpenSSL version 1.0.2 is no longer supported by the OpenSSL \"\n                \"project, please upgrade. The next version of cryptography \"\n                \"will completely remove support for it.\",\n                utils.CryptographyDeprecationWarning,\n            )\n        else:\n            raise RuntimeError(\n                \"You are linking against OpenSSL 1.0.2, which is no longer \"\n                \"supported by the OpenSSL project. You need to upgrade to a \"\n                \"newer version of OpenSSL.\"\n            )\n\n\ndef _verify_package_version(version):\n    # Occasionally we run into situations where the version of the Python\n    # package does not match the version of the shared object that is loaded.\n    # This may occur in environments where multiple versions of cryptography\n    # are installed and available in the python path. To avoid errors cropping\n    # up later this code checks that the currently imported package and the\n    # shared object that were loaded have the same version and raise an\n    # ImportError if they do not\n    so_package_version = ffi.string(lib.CRYPTOGRAPHY_PACKAGE_VERSION)\n    if version.encode(\"ascii\") != so_package_version:\n        raise ImportError(\n            \"The version of cryptography does not match the loaded \"\n            \"shared object. This can happen if you have multiple copies of \"\n            \"cryptography installed in your Python path. Please try creating \"\n            \"a new virtual environment to resolve this issue. \"\n            \"Loaded python version: {}, shared object version: {}\".format(\n                version, so_package_version\n            )\n        )\n\n\n_verify_package_version(cryptography.__version__)\n\n# OpenSSL is not thread safe until the locks are initialized. We call this\n# method in module scope so that it executes with the import lock. On\n# Pythons < 3.4 this import lock is a global lock, which can prevent a race\n# condition registering the OpenSSL locks. On Python 3.4+ the import lock\n# is per module so this approach will not work.\nBinding.init_static_locks()\n\n_verify_openssl_version(Binding.lib)\n", "path": "src/cryptography/hazmat/bindings/openssl/binding.py"}]}