From 54146d90dd5518c24c30e6d2ebeb7f47ed4eb29e Mon Sep 17 00:00:00 2001 From: Andre Heinecke Date: Fri, 8 Jun 2018 14:52:41 +0200 Subject: [PATCH] json: Return fingerprint as createkey result * src/gpgme-json.c (op_createkey): Return fingerprint of new key. --- src/gpgme-json.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/gpgme-json.c b/src/gpgme-json.c index 598c587d..ae878bd0 100644 --- a/src/gpgme-json.c +++ b/src/gpgme-json.c @@ -2778,7 +2778,7 @@ static const char hlp_createkey[] = "expires: Seconds since epoch to expiry as Number. 0 means no expiry.\n" "\n" "Response on success:\n" - "success: Boolean true.\n" + "fingerprint: The fingerprint of the created key.\n" "\n" "Note: This interface does not allow key generation if the userid\n" "of the new key already exists in the keyring.\n"; @@ -2792,6 +2792,7 @@ op_createkey (cjson_t request, cjson_t result) cjson_t j_tmp; const char *algo = "default"; const char *userid; + gpgme_genkey_result_t res; #ifdef GPG_AGENT_ALLOWS_KEYGEN_TRHOUGH_BROWSER /* GnuPG forbids keygen through the browser socket so for @@ -2838,7 +2839,14 @@ op_createkey (cjson_t request, cjson_t result) if ((err = gpgme_op_createkey (ctx, userid, algo, 0, expires, NULL, flags))) goto leave; - xjson_AddBoolToObject (result, "success", 1); + res = gpgme_op_genkey_result (ctx); + if (!res) + { + err = gpg_error (GPG_ERR_GENERAL); + goto leave; + } + + xjson_AddStringToObject0 (result, "fingerprint", res->fpr); leave: #ifdef GPG_AGENT_ALLOWS_KEYGEN_TRHOUGH_BROWSER