Commit ddc07122 authored by Luca Giambonini's avatar Luca Giambonini

fix akabei-key import key (r65)

When calling "akabei-key get B6611E8A" should add the new key to the akabei keychain, but the output is:

sudo akabei-key get B6611E8A
- 5A526467B6611E8A Jeff Huang s8321414@gmail.com
Couldn't find key on the server: End of file

The key was properly downloaded form the server but an error occours.
Based on the gpg documentation (https://www.gnupg.org/documentation/manuals/gpgme/Listing-Keys.html) there is no need to verify that the key is correct.
In fact the original code was wrong, if as input we write 0xB6611E8A the identified key is 5A526467B6611E8A so the if condition is never true:
   if (QString::fromLatin1(key->subkeys->keyid) == id)
furthermore, the key->subkeys->keyid string does not contains the 0x prefix, so the condition is always false.
parent cf415632
......@@ -55,7 +55,7 @@ void printHelp()
out << "import <file>" << endl;
out << " " << QObject::tr("imports and edits a new key from file") << endl;
out << "get <ID>" << endl;
out << " " << QObject::tr("imports the key ID from the keyserver specified in gnupg.conf") << endl;
out << " " << QObject::tr("imports the key ID from the keyserver specified in gpg.conf") << endl;
out << "remove <ID>" << endl;
out << " " << QObject::tr("remove the key identified by ID") << endl;
}
......@@ -271,7 +271,6 @@ void getFromServer(gpgme_ctx_t ctx, QString id)
return;
}
bool found = false;
error = gpgme_op_keylist_start(ctx, id.toUtf8().data(), 0);
if (error) {
......@@ -287,16 +286,11 @@ void getFromServer(gpgme_ctx_t ctx, QString id)
}
out << "- " << key->subkeys->keyid << " " << key->uids->name << " " << key->uids->email << endl;
if (QString::fromLatin1(key->subkeys->keyid) == id) {
found = true;
break;
}
gpgme_key_release(key);
}
if (gpgme_err_code(error) != GPG_ERR_EOF || !found) {
if (gpgme_err_code(error) != GPG_ERR_EOF) {
err << QObject::tr("Couldn't find key on the server: %1").arg( gpgme_strerror(error) ) << endl;
return;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment