Enable TLS for WebSocket

websocket-tls
Andri Yngvason 2023-04-30 16:43:37 +00:00
parent c9a3702940
commit cd030ce503
2 changed files with 13 additions and 4 deletions

View File

@ -21,6 +21,7 @@
#define X_CFG_LIST \ #define X_CFG_LIST \
X(bool, enable_auth) \ X(bool, enable_auth) \
X(bool, enable_tls) \
X(string, private_key_file) \ X(string, private_key_file) \
X(string, certificate_file) \ X(string, certificate_file) \
X(string, username) \ X(string, username) \

View File

@ -740,12 +740,20 @@ int init_nvnc(struct wayvnc* self, const char* addr, uint16_t port,
nvnc_set_name(self->nvnc, "WayVNC"); nvnc_set_name(self->nvnc, "WayVNC");
if (self->cfg.enable_auth && if (self->cfg.enable_auth) {
nvnc_enable_auth(self->nvnc, self->cfg.private_key_file, if (nvnc_enable_auth(self->nvnc, self->cfg.private_key_file,
self->cfg.certificate_file, on_auth, self) < 0) { self->cfg.certificate_file, on_auth, self) < 0) {
nvnc_log(NVNC_LOG_ERROR, "Failed to enable authentication"); nvnc_log(NVNC_LOG_ERROR, "Failed to enable authentication");
goto failure; goto failure;
} }
} else if (self->cfg.enable_tls) {
if (nvnc_load_tls_credentials(self->nvnc,
self->cfg.private_key_file,
self->cfg.certificate_file) < 0) {
nvnc_log(NVNC_LOG_ERROR, "Failed to load TLS credentials");
goto failure;
}
}
if (self->pointer_manager) if (self->pointer_manager)
nvnc_set_pointer_fn(self->nvnc, on_pointer_event); nvnc_set_pointer_fn(self->nvnc, on_pointer_event);