libidav/webdav.c

changeset 147
458a8dc68048
parent 135
664aeaec8d25
child 168
6db9c5d7d7ff
--- a/libidav/webdav.c	Sat Oct 03 16:44:50 2015 +0200
+++ b/libidav/webdav.c	Sat Oct 03 18:11:07 2015 +0200
@@ -185,7 +185,21 @@
 
 DavKey* dav_context_get_key(DavContext *context, char *name) {
     if(name) {
-        return ucx_map_cstr_get(context->keys, name);
+        DavKey *key = ucx_map_cstr_get(context->keys, name);
+        if(key && key->type == DAV_KEY_PASSWORD && !key->data) {
+            char *pw = NULL;
+            if(context->key_input && (pw = context->key_input(context, key))) {
+                // generate key
+                util_generate_key(key, pw);
+            } else {
+                // cannot generate key from password
+                key = NULL;
+            }
+            if(pw) {
+                free(pw);
+            }
+        }
+        return key;
     } else {
         return NULL;
     }

mercurial