diff --git a/gpg.cpp b/gpg.cpp index 4813b35..2cbb06a 100644 --- a/gpg.cpp +++ b/gpg.cpp @@ -102,10 +102,15 @@ std::vector gpg_lookup_key (const std::string& query) command.push_back(query); std::stringstream command_output; if (successful_exit(exec_command(command, command_output))) { + bool is_pubkey = false; while (command_output.peek() != -1) { std::string line; std::getline(command_output, line); - if (line.substr(0, 4) == "fpr:") { + if (line.substr(0, 4) == "pub:") { + is_pubkey = true; + } else if (line.substr(0, 4) == "sub:") { + is_pubkey = false; + } else if (is_pubkey && line.substr(0, 4) == "fpr:") { // fpr:::::::::7A399B2DB06D039020CD1CE1D0F3702D61489532: // want the 9th column (counting from 0) fingerprints.push_back(gpg_nth_column(line, 9));