summaryrefslogtreecommitdiffstats
path: root/gtk/smartcard-manager.c
diff options
context:
space:
mode:
authorChristophe Fergeau <cfergeau@redhat.com>2011-05-16 16:51:57 +0200
committerMarc-André Lureau <marcandre.lureau@gmail.com>2011-06-23 20:01:09 +0200
commitf9539a48ac7017ec0e67cddfcd6d9b50526dc5e5 (patch)
tree9a0d2d9b2b34dd35b793d9819a4462d014237202 /gtk/smartcard-manager.c
parent7c8fae03ee1d3e957fa780b022398bbbae76c611 (diff)
downloadspice-gtk-f9539a48ac7017ec0e67cddfcd6d9b50526dc5e5.tar.gz
spice-gtk-f9539a48ac7017ec0e67cddfcd6d9b50526dc5e5.tar.xz
spice-gtk-f9539a48ac7017ec0e67cddfcd6d9b50526dc5e5.zip
use user-provided certificates when init'ing libcacard
Diffstat (limited to 'gtk/smartcard-manager.c')
-rw-r--r--gtk/smartcard-manager.c40
1 files changed, 39 insertions, 1 deletions
diff --git a/gtk/smartcard-manager.c b/gtk/smartcard-manager.c
index f7fb837..5dcf3d2 100644
--- a/gtk/smartcard-manager.c
+++ b/gtk/smartcard-manager.c
@@ -338,7 +338,45 @@ static guint smartcard_monitor_add(SmartCardSourceFunc callback,
return id;
}
+#define SPICE_SOFTWARE_READER_NAME "Spice Software Smartcard"
+
gboolean spice_smartcard_manager_init_libcacard(SpiceSession *session)
{
- return (vcard_emul_init(NULL) == VCARD_EMUL_OK);
+ char *emul_args;
+ VCardEmulOptions *options = NULL;
+ char *dbname;
+ GStrv certificates;
+
+ g_return_val_if_fail(session != NULL, VCARD_EMUL_FAIL);
+ g_object_get(G_OBJECT(session), "certificate-db", &dbname,
+ "certificates", &certificates,
+ NULL);
+
+ if ((certificates == NULL) || (g_strv_length(certificates) != 3))
+ goto no_certs;
+
+ if (dbname) {
+ emul_args = g_strdup_printf("db=\"%s\" use_hw=no "
+ "soft=(,%s,CAC,,%s,%s,%s)",
+ dbname, SPICE_SOFTWARE_READER_NAME,
+ certificates[0], certificates[1],
+ certificates[2]);
+ } else {
+ emul_args = g_strdup_printf("use_hw=no soft=(,%s,CAC,,%s,%s,%s)",
+ SPICE_SOFTWARE_READER_NAME,
+ certificates[0], certificates[1],
+ certificates[2]);
+ }
+ options = vcard_emul_options(emul_args);
+ g_free(emul_args);
+ if (options == NULL) {
+ g_free(dbname);
+ g_strfreev(certificates);
+ return FALSE;
+ }
+
+no_certs:
+ g_free(dbname);
+ g_strfreev(certificates);
+ return (vcard_emul_init(options) == VCARD_EMUL_OK);
}