Skip to content
Merged
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
3 changes: 3 additions & 0 deletions build_profile.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"enabled_classes": [
"OS",
"EditorVCSInterface",
"ProjectSettings",
"FileAccess",
"DirAccess",
"Window"
]
}
19 changes: 19 additions & 0 deletions godot-git-plugin/src/git_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
#include <git2/tree.h>
#include "godot_cpp/core/class_db.hpp"
#include "godot_cpp/classes/file_access.hpp"
#include "godot_cpp/classes/dir_access.hpp"
#include "godot_cpp/classes/os.hpp"
#include "godot_cpp/classes/project_settings.hpp"
#include "godot_cpp/variant/utility_functions.hpp"

#define GIT2_CALL(error, msg) \
Expand Down Expand Up @@ -701,6 +704,22 @@ bool GitPlugin::_initialize(const godot::String &project_path) {
create_gitignore_and_gitattributes();
}

// We need to create a temporary file to load the CA from (libgit2 does not support loading certificates from string or raw pem).
const String cafile = ProjectSettings::get_singleton()->globalize_path("res://.godot/git-cas" + OS::get_singleton()->get_entropy(8).hex_encode() + ".crt");
godot::Ref<godot::FileAccess> file = godot::FileAccess::open(cafile, godot::FileAccess::WRITE_READ);
if (file.is_null()) {
return false;
}
file->store_buffer(OS::get_singleton()->get_system_ca_certificates().to_utf8_buffer());
file->close();
int error = git_libgit2_opts(GIT_OPT_SET_SSL_CERT_LOCATIONS, cafile.utf8().get_data(), NULL);
DirAccess::remove_absolute(cafile); // Always remove the file
if (unlikely(error)) {
ERR_PRINT("GitPlugin: Failed to load CA bundle: " + cafile + ", error: " + itos(error));
} else {
godot::UtilityFunctions::print("GitPlugin: Loaded system CA certificates");
}

return true;
}

Expand Down
Loading