Add config parameter for RSA private key file

pull/143/merge
Andri Yngvason 2023-09-10 17:19:25 +00:00
parent 3a01753a22
commit 8395f7b106
2 changed files with 22 additions and 7 deletions

View File

@ -23,6 +23,7 @@
X(bool, enable_auth) \
X(string, private_key_file) \
X(string, certificate_file) \
X(string, rsa_private_key_file) \
X(string, username) \
X(string, password) \
X(string, address) \

View File

@ -740,13 +740,27 @@ int init_nvnc(struct wayvnc* self, const char* addr, uint16_t port,
nvnc_set_name(self->nvnc, "WayVNC");
if (self->cfg.enable_auth && self->cfg.private_key_file[0] == '\0') {
nvnc_enable_auth2(self->nvnc, on_auth, self);
} else if (self->cfg.enable_auth &&
nvnc_enable_auth(self->nvnc, self->cfg.private_key_file,
self->cfg.certificate_file, on_auth, self) < 0) {
nvnc_log(NVNC_LOG_ERROR, "Failed to enable authentication");
goto failure;
if (self->cfg.enable_auth) {
if (self->cfg.rsa_private_key_file) {
if (nvnc_enable_auth2(self->nvnc, on_auth, self) < 0) {
nvnc_log(NVNC_LOG_ERROR, "Failed to enable RSA authentication");
goto failure;
}
if (nvnc_set_rsa_creds(self->nvnc, self->cfg.rsa_private_key_file) < 0) {
nvnc_log(NVNC_LOG_ERROR, "Failed to load RSA credentials");
goto failure;
}
}
if (self->cfg.private_key_file) {
int r = nvnc_enable_auth(self->nvnc, self->cfg.private_key_file,
self->cfg.certificate_file, on_auth, self);
if (r < 0) {
nvnc_log(NVNC_LOG_ERROR, "Failed to enable TLS authentication");
goto failure;
}
}
}
if (self->pointer_manager)