Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

969 B
Raw Blame
# SPDX-License-Identifier: AGPL-3.0-only
# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0

import os
import sys


def drop_unwritable_ssl_keylog_file():
    """Unset SSLKEYLOGFILE if it cannot be appended: ssl.create_default_context opens it per
    context, so an unwritable path makes every HTTPS client raise; security software sets it
    machine-wide."""
    path = os.environ.get("SSLKEYLOGFILE")
    if not path:
        return False
    try:
        with open(path, "a", encoding = "utf-8"):
            pass
        return False
    except OSError as exc:
        os.environ.pop("SSLKEYLOGFILE", None)
        try:
            print(
                f"Unsloth: ignoring SSLKEYLOGFILE={path!r}, which this process cannot "
                f"write ({type(exc).__name__}); TLS key logging is off.",
                file = sys.stderr,
            )
        except Exception:
            pass
        return True