Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions addons/godot-git-plugin/ca_cert_config.txt
Original file line number Diff line number Diff line change
@@ -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
49 changes: 48 additions & 1 deletion godot-git-plugin/src/git_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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<godot::FileAccess> 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;
}

Expand Down
2 changes: 2 additions & 0 deletions godot-git-plugin/src/git_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class GitPlugin : public godot::EditorVCSInterface {
git_oid pull_merge_oid = {};
godot::String repo_project_path;
std::unordered_map<git_status_t, ChangeType> map_changes;
godot::String ca_bundle_path;

GitPlugin();

Expand Down Expand Up @@ -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<godot::Dictionary> _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<godot::Dictionary> _parse_diff(git_diff *p_diff);
Expand Down