from pathlib import Path


def load_custom_ca(ca_path):
    """Load custom CA with key from path."""
    ca_file = Path(ca_path)

    if Path.is_file(ca_file):
        file_name = Path(ca_file).stem
        base_name = Path(file_name).name
        # check key exists:
        key_file = Path(f"{ca_file.parents[0]}/{base_name}.key")
        if not Path.is_file(key_file):
            raise IOError("Key file does not exists")
        return (ca_file, key_file)
    else:
        raise IOError("CA file does not exists")