diff options
author | Christophe Fergeau <cfergeau@redhat.com> | 2018-03-30 09:13:33 +0200 |
---|---|---|
committer | Christophe Fergeau <cfergeau@redhat.com> | 2018-04-05 10:46:43 +0200 |
commit | 89f0dfa01ed2ab8c2a2b0067ecd4a3d17fc67191 (patch) | |
tree | 942d2d18f063f9aa6ef8bfee2203c35f284209e0 | |
parent | 1852f5697b50b30168d586daa599f7f230657f0e (diff) |
reds: Split part of spice_server_set_tls in a helper
This will be useful in a subsequent commit.
-rw-r--r-- | server/reds.c | 37 |
1 files 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; } |