summaryrefslogtreecommitdiffstats
path: root/modules/websocket/websocket_client.cpp
diff options
context:
space:
mode:
authorFabio Alessandrelli <fabio.alessandrelli@gmail.com>2019-10-07 15:38:03 +0200
committerFabio Alessandrelli <fabio.alessandrelli@gmail.com>2019-10-09 13:53:04 +0200
commit33644d711865e518a792403304b09f0828478fe9 (patch)
tree7ec5a2e73d74ab632d73d420e90d301cae0d3a49 /modules/websocket/websocket_client.cpp
parent025cc04d9e8ec12cea749b6831fb8bc5c78894e2 (diff)
downloadredot-engine-33644d711865e518a792403304b09f0828478fe9.tar.gz
WebSocketClient can now use custom SSL certificate
Via the `trusted_ssl_certificate` property.
Diffstat (limited to 'modules/websocket/websocket_client.cpp')
-rw-r--r--modules/websocket/websocket_client.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/modules/websocket/websocket_client.cpp b/modules/websocket/websocket_client.cpp
index 8f03efdd83..df6578e8bb 100644
--- a/modules/websocket/websocket_client.cpp
+++ b/modules/websocket/websocket_client.cpp
@@ -85,6 +85,17 @@ bool WebSocketClient::is_verify_ssl_enabled() const {
return verify_ssl;
}
+Ref<X509Certificate> WebSocketClient::get_trusted_ssl_certificate() const {
+
+ return ssl_cert;
+}
+
+void WebSocketClient::set_trusted_ssl_certificate(Ref<X509Certificate> p_cert) {
+
+ ERR_FAIL_COND(get_connection_status() != CONNECTION_DISCONNECTED);
+ ssl_cert = p_cert;
+}
+
bool WebSocketClient::is_server() const {
return false;
@@ -141,6 +152,11 @@ void WebSocketClient::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "verify_ssl", PROPERTY_HINT_NONE, "", 0), "set_verify_ssl_enabled", "is_verify_ssl_enabled");
+ ClassDB::bind_method(D_METHOD("get_trusted_ssl_certificate"), &WebSocketClient::get_trusted_ssl_certificate);
+ ClassDB::bind_method(D_METHOD("set_trusted_ssl_certificate"), &WebSocketClient::set_trusted_ssl_certificate);
+
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "trusted_ssl_certificate", PROPERTY_HINT_RESOURCE_TYPE, "X509Certificate", 0), "set_trusted_ssl_certificate", "get_trusted_ssl_certificate");
+
ADD_SIGNAL(MethodInfo("data_received"));
ADD_SIGNAL(MethodInfo("connection_established", PropertyInfo(Variant::STRING, "protocol")));
ADD_SIGNAL(MethodInfo("server_close_request", PropertyInfo(Variant::INT, "code"), PropertyInfo(Variant::STRING, "reason")));