summaryrefslogtreecommitdiff
path: root/client/gtk.c
diff options
context:
space:
mode:
authorMarcus Carlson <marcus@tajt.nu>2010-06-14 00:08:01 +0200
committerSamuel Lidén Borell <samuel@slbdata.se>2010-06-15 23:19:41 +0200
commitf27dc2e5e004ef90703fdc7121694804120f00a4 (patch)
treec0da588215e3154ec1a44b5e10783d4b4beff6ef /client/gtk.c
parent63e04b4b34ca7b196831f8e53cf7dfdd256383ba (diff)
downloadfribid-f27dc2e5e004ef90703fdc7121694804120f00a4.tar.gz
fribid-f27dc2e5e004ef90703fdc7121694804120f00a4.tar.bz2
fribid-f27dc2e5e004ef90703fdc7121694804120f00a4.zip
Only list certificates with the correct keyusage when doing authentication/signing
Diffstat (limited to 'client/gtk.c')
-rw-r--r--client/gtk.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/client/gtk.c b/client/gtk.c
index 125c347..6214a52 100644
--- a/client/gtk.c
+++ b/client/gtk.c
@@ -91,6 +91,8 @@ static GtkWidget *signScroller;
static char *currentSubjectFilter;
static bool dialogShown;
+static int currentKeyUsage;
+
static void showMessage(GtkMessageType type, const char *text) {
GtkWidget *dialog = gtk_message_dialog_new(
GTK_WINDOW(signDialog), GTK_DIALOG_DESTROY_WITH_PARENT,
@@ -105,14 +107,14 @@ static void validateDialog(GtkWidget *ignored1, gpointer *ignored2) {
}
static bool addSignatureFile(GtkListStore *signatures, const char *filename,
- GtkTreeIter *iter) {
+ GtkTreeIter *iter, int keyUsage) {
int fileLen;
char *fileData;
platform_readFile(filename, &fileData, &fileLen);
int personCount;
KeyfileSubject **people = NULL;
- keyfile_listPeople(fileData, fileLen, &people, &personCount);
+ keyfile_listPeople(fileData, fileLen, &people, &personCount, keyUsage);
for (int i = 0; i < personCount; i++) {
if (keyfile_matchSubjectFilter(people[i], currentSubjectFilter)) {
@@ -177,10 +179,13 @@ static void selectDefaultSignature() {
}
void platform_startSign(const char *url, const char *hostname, const char *ip,
- const char *subjectFilter, unsigned long parentWindowId) {
+ const char *subjectFilter, unsigned long parentWindowId,
+ int keyUsage) {
char** paths;
int len;
+ currentKeyUsage = keyUsage;
+
currentSubjectFilter = (subjectFilter != NULL ?
strdup(subjectFilter) : NULL);
@@ -215,7 +220,7 @@ void platform_startSign(const char *url, const char *hostname, const char *ip,
if (dir) {
while (platform_iterateDir(dir)) {
char *filename = platform_currentPath(dir);
- addSignatureFile(signatures, filename, &iter);
+ addSignatureFile(signatures, filename, &iter, keyUsage);
free(filename);
}
platform_closeDir(dir);
@@ -329,7 +334,7 @@ static void selectExternalFile() {
// Add an item to the signatures list and select it
GtkTreeIter iter = { .stamp = 0 };
- ok = addSignatureFile(GTK_LIST_STORE(signatures), filename, &iter);
+ ok = addSignatureFile(GTK_LIST_STORE(signatures), filename, &iter, currentKeyUsage);
if (ok) gtk_combo_box_set_active_iter(signaturesCombo, &iter);
g_free(filename);