diff --git a/scripts/curl_install_pypi/install.py b/scripts/curl_install_pypi/install.py index 09a3df24dc3..f03b4eb8570 100644 --- a/scripts/curl_install_pypi/install.py +++ b/scripts/curl_install_pypi/install.py @@ -23,8 +23,27 @@ import shutil import subprocess import hashlib +import ssl from urllib.request import urlopen +def _create_ssl_context(): + # Attempt to use system's default CA certificates (works on most platforms) + try: + return ssl.create_default_context() + except ssl.SSLError: + pass + # Fallback to certifi if available (e.g., in virtualenvs with requests installed) + try: + import certifi + return ssl.create_default_context(cafile=certifi.where()) + except ImportError: + pass + # Last resort: no verification (NOT recommended, but lets users proceed if they accept the risk) + context = ssl.create_default_context() + context.check_hostname = False + context.verify_mode = ssl.CERT_NONE + return context + AZ_DISPATCH_TEMPLATE = """#!/usr/bin/env bash {install_dir}/bin/python -m azure.cli "$@" """