comparison mcabber/src/pgp.c @ 1049:ad5de4d1ee56

PGP: Give a more useful error message when the private key isn't found
author Mikael Berthe <mikael@lilotux.net>
date Sun, 26 Nov 2006 20:08:18 +0100
parents 0dc104d51dce
children 082d55152a25
comparison
equal deleted inserted replaced
1048:a743eaa94d94 1049:ad5de4d1ee56
272 p = getenv("GPG_AGENT_INFO"); 272 p = getenv("GPG_AGENT_INFO");
273 if (!(p && strchr(p, ':'))) 273 if (!(p && strchr(p, ':')))
274 gpgme_set_passphrase_cb(ctx, passphrase_cb, 0); 274 gpgme_set_passphrase_cb(ctx, passphrase_cb, 0);
275 275
276 err = gpgme_get_key(ctx, gpg.private_key, &key, 1); 276 err = gpgme_get_key(ctx, gpg.private_key, &key, 1);
277 if (!err) { 277 if (err) {
278 gpgme_signers_clear(ctx); 278 scr_LogPrint(LPRINT_LOGNORM, "GPGME error: private key not found");
279 gpgme_signers_add(ctx, key); 279 gpgme_release(ctx);
280 gpgme_key_release(key); 280 return NULL;
281 err = gpgme_data_new_from_mem(&in, gpg_data, strlen(gpg_data), 0); 281 }
282 } 282
283 gpgme_signers_clear(ctx);
284 gpgme_signers_add(ctx, key);
285 gpgme_key_release(key);
286 err = gpgme_data_new_from_mem(&in, gpg_data, strlen(gpg_data), 0);
283 if (!err) { 287 if (!err) {
284 err = gpgme_data_new(&out); 288 err = gpgme_data_new(&out);
285 if (!err) { 289 if (!err) {
286 err = gpgme_op_sign(ctx, in, out, GPGME_SIG_MODE_DETACH); 290 err = gpgme_op_sign(ctx, in, out, GPGME_SIG_MODE_DETACH);
287 if (!err) { 291 if (!err) {