User-Agent reflects the version of openssl used to connect
@@ -27,6 +27,7 @@ from pip._vendor.six.moves import xmlrpc_client # type: ignore
from pip._vendor.six.moves.urllib import parse as urllib_parse
from pip._vendor.six.moves.urllib import request as urllib_request
from pip._vendor.six.moves.urllib.parse import unquote as urllib_unquote
+from pip._vendor.urllib3.util import IS_PYOPENSSL
import pip
from pip._internal.exceptions import HashMismatch, InstallationError
@@ -46,11 +47,17 @@ from pip._internal.utils.temp_dir import TempDirectory
from pip._internal.utils.ui import DownloadProgressProvider
from pip._internal.vcs import vcs
+try:
+ import OpenSSL # noqa
+except ImportError:
+ OpenSSL = None
+
try:
import ssl # noqa
- HAS_TLS = True
except ImportError:
- HAS_TLS = False
+ ssl = None
+
+HAS_TLS = (ssl is not None) or (OpenSSL is not None and IS_PYOPENSSL)
__all__ = ['get_file_content',
'is_url', 'url_to_path', 'path_to_url',
@@ -119,6 +126,9 @@ def user_agent():
data["cpu"] = platform.machine()
if HAS_TLS:
+ if IS_PYOPENSSL:
+ data["openssl_version"] = OpenSSL.SSL.OPENSSL_VERSION_NUMBER
+ else:
data["openssl_version"] = ssl.OPENSSL_VERSION
setuptools_version = get_installed_version("setuptools")
