|
@@ -29,6 +29,8 @@
|
|
|
/*************************************************************************/
|
|
|
|
|
|
#include "stream_peer_ssl.h"
|
|
|
+#include "os/file_access.h"
|
|
|
+#include "project_settings.h"
|
|
|
|
|
|
StreamPeerSSL *(*StreamPeerSSL::_create)() = NULL;
|
|
|
|
|
@@ -50,6 +52,35 @@ bool StreamPeerSSL::is_available() {
|
|
|
return available;
|
|
|
}
|
|
|
|
|
|
+PoolByteArray StreamPeerSSL::get_project_cert_array() {
|
|
|
+
|
|
|
+ PoolByteArray out;
|
|
|
+ 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"));
|
|
|
+
|
|
|
+ if (certs_path != "") {
|
|
|
+
|
|
|
+ FileAccess *f = FileAccess::open(certs_path, FileAccess::READ);
|
|
|
+ if (f) {
|
|
|
+ int flen = f->get_len();
|
|
|
+ out.resize(flen + 1);
|
|
|
+ {
|
|
|
+ PoolByteArray::Write w = out.write();
|
|
|
+ f->get_buffer(w.ptr(), flen);
|
|
|
+ w[flen] = 0; //end f string
|
|
|
+ }
|
|
|
+
|
|
|
+ memdelete(f);
|
|
|
+
|
|
|
+#ifdef DEBUG_ENABLED
|
|
|
+ print_line("Loaded certs from '" + certs_path);
|
|
|
+#endif
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return out;
|
|
|
+}
|
|
|
+
|
|
|
void StreamPeerSSL::_bind_methods() {
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("poll"), &StreamPeerSSL::poll);
|