diff --git a/addons/godot-git-plugin/ca_cert_config.txt b/addons/godot-git-plugin/ca_cert_config.txt new file mode 100644 index 00000000..dcf15de7 --- /dev/null +++ b/addons/godot-git-plugin/ca_cert_config.txt @@ -0,0 +1,53 @@ +# CA Certificate Bundle Configuration for godot-git-plugin +# +# This file allows you to specify a custom CA certificate bundle path +# to resolve SSL certificate validation errors on all platforms. +# +# INSTRUCTIONS: +# 1. Uncomment the line that matches your system +# 2. Adjust the path if your certificates are located elsewhere +# 3. Restart Godot after making changes + +# +# ============================================================ +# LINUX - Common certificate bundle locations: +# ============================================================ + +# Linux (Debian/Ubuntu/Mint) +#/etc/ssl/certs/ca-certificates.crt + +# Linux (RHEL/CentOS/Fedora) +# /etc/pki/tls/certs/ca-bundle.crt + +# Linux (OpenSUSE) +# /etc/ssl/ca-bundle.pem + +# Custom path +# /path/to/your/ca-bundle.crt + +# ============================================================ +# MACOS - Common certificate bundle locations: +# ============================================================ + +# macOS (Homebrew OpenSSL) +# /usr/local/etc/openssl@3/cert.pem + +# macOS (System) +# /etc/ssl/cert.pem + +# Custom path +# /path/to/your/ca-bundle.crt + +# ============================================================ +# WINDOWS - Common certificate bundle locations: +# ============================================================ + +# Use forward slashes (/) in paths, even on Windows +# Git backend selection during installation doesn't affect this plugin +# Git for Windows (works with both OpenSSL and Secure Channel installations) +# Possible Windows Paths for cert included with Git +# C:/Program Files/Git/mingw64/etc/ssl/certs/ca-bundle.crt +# C:/Program Files/Git/usr/ssl/certs/ca-bundle.crt + +# Custom path +# C:/path/to/your/ca-bundle.crt \ No newline at end of file diff --git a/godot-git-plugin/src/git_plugin.cpp b/godot-git-plugin/src/git_plugin.cpp index af7360a1..452ecd21 100644 --- a/godot-git-plugin/src/git_plugin.cpp +++ b/godot-git-plugin/src/git_plugin.cpp @@ -29,8 +29,37 @@ #define COMMA , +godot::String get_plugin_base_path() { + return "res://addons/godot-git-plugin/"; +} + void GitPlugin::_bind_methods() { - // Doesn't seem to require binding functions for now + godot::ClassDB::bind_method(godot::D_METHOD("set_ca_bundle_path", "path"), &GitPlugin::_set_ca_bundle_path); +} + +void GitPlugin::_set_ca_bundle_path(const godot::String &path) { + // Store path for later use. If empty, default runtime behavior remains unchanged. + ca_bundle_path = path; + + if (!ca_bundle_path.is_empty()) { + // Normalize path (convert backslashes to forward slashes) + godot::String normalized_path = ca_bundle_path.replace("\\", "/"); + + // Convert to C string + std::string path_str = std::string(normalized_path.utf8().get_data()); + + // Tell libgit2 to use this certificate file + int error = git_libgit2_opts(GIT_OPT_SET_SSL_CERT_LOCATIONS, path_str.c_str(), NULL); + + if (error == 0) { + godot::UtilityFunctions::print("GitPlugin: CA bundle set to ", normalized_path); + } else { + const git_error *e = git_error_last(); + godot::UtilityFunctions::print("GitPlugin: Failed to set CA bundle: ", e ? e->message : "unknown error"); + } + } else { + godot::UtilityFunctions::print("GitPlugin: CA bundle cleared"); + } } GitPlugin::GitPlugin() { @@ -701,6 +730,24 @@ bool GitPlugin::_initialize(const godot::String &project_path) { create_gitignore_and_gitattributes(); } + godot::String config_path = "res://addons/godot-git-plugin/ca_cert_config.txt"; + if (godot::FileAccess::file_exists(config_path)) { + godot::UtilityFunctions::print("GitPlugin: file_exists ", config_path); + godot::Ref file = + godot::FileAccess::open(config_path, godot::FileAccess::READ); + if (file.is_valid()) { + while (!file->eof_reached()) { + godot::String line = file->get_line().strip_edges(); + if (line.is_empty() || line.begins_with("#")) { + continue; + } + _set_ca_bundle_path(line); + break; + } + file->close(); + } + } + return true; } diff --git a/godot-git-plugin/src/git_plugin.h b/godot-git-plugin/src/git_plugin.h index eb2a7dd9..57ea0042 100644 --- a/godot-git-plugin/src/git_plugin.h +++ b/godot-git-plugin/src/git_plugin.h @@ -29,6 +29,7 @@ class GitPlugin : public godot::EditorVCSInterface { git_oid pull_merge_oid = {}; godot::String repo_project_path; std::unordered_map map_changes; + godot::String ca_bundle_path; GitPlugin(); @@ -56,6 +57,7 @@ class GitPlugin : public godot::EditorVCSInterface { void _push(const godot::String &remote, bool force) override; void _fetch(const godot::String &remote) override; godot::TypedArray _get_line_diff(const godot::String &file_path, const godot::String &text) override; + void _set_ca_bundle_path(const godot::String &path); // Helpers godot::TypedArray _parse_diff(git_diff *p_diff);