Mercurial > ~mikael > mcabber > hg
comparison mcabber/src/pgp.c @ 1105:265e1d873d3e
PGP: Improve checks for missing keys
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Wed, 13 Dec 2006 22:05:43 +0100 |
parents | 4cdf19d9c74e |
children | 2de8f8ba1f34 |
comparison
equal
deleted
inserted
replaced
1104:382972712208 | 1105:265e1d873d3e |
---|---|
219 if (!err) { | 219 if (!err) { |
220 gpgme_verify_result_t vr = gpgme_op_verify_result(ctx); | 220 gpgme_verify_result_t vr = gpgme_op_verify_result(ctx); |
221 if (vr && vr->signatures) { | 221 if (vr && vr->signatures) { |
222 char *r = vr->signatures->fpr; | 222 char *r = vr->signatures->fpr; |
223 // Found the fingerprint. Let's try to get the key id. | 223 // Found the fingerprint. Let's try to get the key id. |
224 if(!gpgme_get_key(ctx, r, &key, 0)) { | 224 if (!gpgme_get_key(ctx, r, &key, 0) && key) { |
225 r = key->subkeys->keyid; | 225 r = key->subkeys->keyid; |
226 gpgme_key_release(key); | 226 gpgme_key_release(key); |
227 } | 227 } |
228 // r is a static variable, let's copy it. | 228 // r is a static variable, let's copy it. |
229 verified_key = g_strdup(r); | 229 verified_key = g_strdup(r); |
276 p = getenv("GPG_AGENT_INFO"); | 276 p = getenv("GPG_AGENT_INFO"); |
277 if (!(p && strchr(p, ':'))) | 277 if (!(p && strchr(p, ':'))) |
278 gpgme_set_passphrase_cb(ctx, passphrase_cb, 0); | 278 gpgme_set_passphrase_cb(ctx, passphrase_cb, 0); |
279 | 279 |
280 err = gpgme_get_key(ctx, gpg.private_key, &key, 1); | 280 err = gpgme_get_key(ctx, gpg.private_key, &key, 1); |
281 if (err) { | 281 if (err || !key) { |
282 scr_LogPrint(LPRINT_LOGNORM, "GPGME error: private key not found"); | 282 scr_LogPrint(LPRINT_LOGNORM, "GPGME error: private key not found"); |
283 gpgme_release(ctx); | 283 gpgme_release(ctx); |
284 return NULL; | 284 return NULL; |
285 } | 285 } |
286 | 286 |
402 gpgme_set_protocol(ctx, GPGME_PROTOCOL_OpenPGP); | 402 gpgme_set_protocol(ctx, GPGME_PROTOCOL_OpenPGP); |
403 gpgme_set_textmode(ctx, 0); | 403 gpgme_set_textmode(ctx, 0); |
404 gpgme_set_armor(ctx, 1); | 404 gpgme_set_armor(ctx, 1); |
405 | 405 |
406 err = gpgme_get_key(ctx, keyid, &key, 0); | 406 err = gpgme_get_key(ctx, keyid, &key, 0); |
407 if (!err) { | 407 if (!err && key) { |
408 gpgme_key_t keys[] = { key, 0 }; | 408 gpgme_key_t keys[] = { key, 0 }; |
409 err = gpgme_data_new_from_mem(&in, gpg_data, strlen(gpg_data), 0); | 409 err = gpgme_data_new_from_mem(&in, gpg_data, strlen(gpg_data), 0); |
410 if (!err) { | 410 if (!err) { |
411 err = gpgme_data_new(&out); | 411 err = gpgme_data_new(&out); |
412 if (!err) { | 412 if (!err) { |