blob: 7ca9b074a481e579f1dab01cb2bfa5730bd595a2 [file] [log] [blame]
diff --git csrc/lib/ccn_client.c csrc/lib/ccn_client.c
index 606fd36..2642e0c 100644
--- csrc/lib/ccn_client.c
+++ csrc/lib/ccn_client.c
@@ -2435,6 +2435,7 @@ ccn_load_private_key(struct ccn *h,
res = NOTE_ERRNO(h);
goto Cleanup;
}
+ printf (">>> load_private_key: [%s]\n", keystore_path);
res = ccn_keystore_init(keystore,
(char *)keystore_path,
(char *)keystore_passphrase);
@@ -2487,6 +2488,7 @@ ccn_load_default_key(struct ccn *h,
if (h->default_pubid != NULL)
return(NOTE_ERR(h, EINVAL));
default_pubid = ccn_charbuf_create();
+ printf ("Tring to open keystore [%s]\n", keystore_path);
res = ccn_load_private_key(h,
keystore_path,
keystore_passphrase,
@@ -2607,23 +2609,55 @@ ccn_chk_signing_params(struct ccn *h,
temp = ccn_charbuf_create();
if (default_pubid == NULL || temp == NULL)
return(NOTE_ERRNO(h));
- ccnx_dir = getenv("CCNX_DIR");
- if (ccnx_dir == NULL || ccnx_dir[0] == 0) {
- home = getenv("HOME");
- if (home == NULL)
- home = "";
- ccn_charbuf_putf(temp, "%s/.ccnx/.ccnx_keystore", home);
+
+ res = -1;
+#ifdef CCNX_DIR
+ if (res < 0 || default_pubid->length != sizeof(result->pubid)) {
+ // check preconfigured directory
+ ccnx_dir = CCNX_DIR;
+ if (ccnx_dir != NULL && ccnx_dir[0] != 0) {
+ ccn_charbuf_putf(temp, "%s/.ccnx_keystore", ccnx_dir);
+
+ res = ccn_load_private_key(h,
+ ccn_charbuf_as_string(temp),
+ "Th1s1sn0t8g00dp8ssw0rd.",
+ default_pubid);
+ }
}
- else
+#endif
+
+ if (res < 0 || default_pubid->length != sizeof(result->pubid)) {
+ // check CCNX_DIR
+ ccnx_dir = getenv("CCNX_DIR");
+ if (ccnx_dir != NULL && ccnx_dir[0] != 0) {
ccn_charbuf_putf(temp, "%s/.ccnx_keystore", ccnx_dir);
- res = ccn_load_private_key(h,
- ccn_charbuf_as_string(temp),
- "Th1s1sn0t8g00dp8ssw0rd.",
- default_pubid);
+
+ res = ccn_load_private_key(h,
+ ccn_charbuf_as_string(temp),
+ "Th1s1sn0t8g00dp8ssw0rd.",
+ default_pubid);
+ }
+ }
+
+ if (res < 0 || default_pubid->length != sizeof(result->pubid)) {
+ // check HOME
+ home = getenv("HOME");
+ if (home != NULL) {
+ ccn_charbuf_putf(temp, "%s/.ccnx/.ccnx_keystore", home);
+ res = ccn_load_private_key(h,
+ ccn_charbuf_as_string(temp),
+ "Th1s1sn0t8g00dp8ssw0rd.",
+ default_pubid);
+ }
+ }
+
if (res == 0 && default_pubid->length == sizeof(result->pubid)) {
h->default_pubid = default_pubid;
default_pubid = NULL;
}
+ else {
+ ccn_perror(h, ccn_charbuf_as_string(temp));
+ }
}
if (h->default_pubid == NULL)
res = NOTE_ERRNO(h);