Emit SPICE_CHANNEL_ERROR_TLS when certificate can't be found

When trying to start remote-viewer with SPICE over TLS with
--spice-ca-file with a wrong filename, the connection fails
but remote-viewer keeps displaying the "Trying to connect"
message. The only hint that something went wrong is:
(remote-viewer:12924): GSpice-WARNING **: loading ca certs from a/home/teuf/foo.crt

This patch makes sure we emit a SPICE_CHANNEL_ERROR_TLS before
giving up on channel creation to inform the application that
an error happened.
This commit is contained in:
Christophe Fergeau 2012-06-10 23:30:13 +02:00
parent 331cba23cc
commit 5a36c87faa

View File

@ -2144,15 +2144,16 @@ reconnect:
g_warn_if_fail(ca_file != NULL);
SPICE_DEBUG("CA file: %s", ca_file);
rc = SSL_CTX_load_verify_locations(c->ctx, ca_file, NULL);
if (rc != 1)
g_warning("loading ca certs from %s failed", ca_file);
if (rc != 1) {
g_warning("loading ca certs from %s failed", ca_file);
if (verify & SPICE_SESSION_VERIFY_PUBKEY) {
g_warning("only pubkey active");
verify = SPICE_SESSION_VERIFY_PUBKEY;
} else
} else {
emit_main_context(channel, SPICE_CHANNEL_EVENT, SPICE_CHANNEL_ERROR_TLS);
goto cleanup;
}
}
}