1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-07 12:30:27 +00:00

Generalize SSL cert reading from file

This commit is contained in:
Fabio Alessandrelli
2018-03-28 16:26:25 +02:00
parent d97c45ad2e
commit 490dd9f946
4 changed files with 35 additions and 23 deletions

View File

@@ -293,28 +293,10 @@ void StreamPeerMbedTLS::initialize_ssl() {
mbedtls_debug_set_threshold(1);
#endif
String certs_path = GLOBAL_DEF("network/ssl/certificates", "");
ProjectSettings::get_singleton()->set_custom_property_info("network/ssl/certificates", PropertyInfo(Variant::STRING, "network/ssl/certificates", PROPERTY_HINT_FILE, "*.crt"));
PoolByteArray cert_array = StreamPeerSSL::get_project_cert_array();
if (certs_path != "") {
FileAccess *f = FileAccess::open(certs_path, FileAccess::READ);
if (f) {
PoolByteArray arr;
int flen = f->get_len();
arr.resize(flen + 1);
{
PoolByteArray::Write w = arr.write();
f->get_buffer(w.ptr(), flen);
w[flen] = 0; //end f string
}
memdelete(f);
_load_certs(arr);
print_line("Loaded certs from '" + certs_path);
}
}
if (cert_array.size() > 0)
_load_certs(cert_array);
available = true;
}