From 89f0dfa01ed2ab8c2a2b0067ecd4a3d17fc67191 Mon Sep 17 00:00:00 2001 From: Christophe Fergeau Date: Fri, 30 Mar 2018 09:13:33 +0200 Subject: reds: Split part of spice_server_set_tls in a helper This will be useful in a subsequent commit. --- server/reds.c | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/server/reds.c b/server/reds.c index 42535f9b..f3f6e24c 100644 --- a/server/reds.c +++ b/server/reds.c @@ -3828,21 +3828,16 @@ SPICE_GNUC_VISIBLE int spice_server_set_ticket(SpiceServer *reds, return 0; } -SPICE_GNUC_VISIBLE int spice_server_set_tls(SpiceServer *s, int port, - const char *ca_cert_file, const char *certs_file, - const char *private_key_file, const char *key_passwd, - const char *dh_key_file, const char *ciphersuite) +static int spice_server_set_tls_options(SpiceServer *s, + const char *ca_cert_file, const char *certs_file, + const char *private_key_file, const char *key_passwd, + const char *dh_key_file, const char *ciphersuite) { - if (port == 0 || ca_cert_file == NULL || certs_file == NULL || - private_key_file == NULL) { - return -1; - } - if (port < 0 || port > 0xffff) { + if (ca_cert_file == NULL || certs_file == NULL || private_key_file == NULL) { return -1; } memset(&s->config->ssl_parameters, 0, sizeof(s->config->ssl_parameters)); - s->config->spice_secure_port = port; g_strlcpy(s->config->ssl_parameters.ca_certificate_file, ca_cert_file, sizeof(s->config->ssl_parameters.ca_certificate_file)); g_strlcpy(s->config->ssl_parameters.certs_file, certs_file, @@ -3862,6 +3857,28 @@ SPICE_GNUC_VISIBLE int spice_server_set_tls(SpiceServer *s, int port, g_strlcpy(s->config->ssl_parameters.dh_key_file, dh_key_file, sizeof(s->config->ssl_parameters.dh_key_file)); } + + return 0; +} + +int spice_server_set_tls(SpiceServer *s, int port, + const char *ca_cert_file, const char *certs_file, + const char *private_key_file, const char *key_passwd, + const char *dh_key_file, const char *ciphersuite) +{ + int res; + if (port <= 0 || port > 0xffff) { + return -1; + } + res = spice_server_set_tls_options(s, + ca_cert_file, certs_file, + private_key_file, key_passwd, + dh_key_file, ciphersuite); + if (res != 0) { + return -1; + } + s->config->spice_secure_port = port; + return 0; } -- cgit v1.2.3