"""
certifi.py
~~~~~~~~~~

This module returns the installation location of cacert.pem or its contents.
Patched by openSUSE: return the system bundle
"""
import io
import os
import os.path


def read_text(_module=None, _path=None, encoding="ascii"):
    with io.open(where(), "r", encoding=encoding) as data:
        return data.read()


def where():
    # Try the legacy location first
    legacy_path = "/etc/ssl/ca-bundle.pem"
    if os.path.exists(legacy_path):
        return legacy_path

    # Try the primary location
    primary_path = "/var/lib/ca-certificates/ca-bundle.pem"
    if os.path.exists(primary_path):
        return primary_path

    # Return None to let Python use system defaults
    return None


def contents() -> str:
    return read_text(encoding="ascii")
