>Don't give up!

>So far we've cleared two major problems: the first was GnuPG taking ~15
>minutes to generate a certificate, and the second was GPGME not working
>with your callback.  Two major problems solved in two days.  Imagine
>what we can get solved by the end of the week.

>Programming is hard, but you're not stupid, and you're in a place where
>you can get help.  Stick with it.  Things will be okay.

Thank you for this encouraging words. In fact I got solved another problem.
It seems that the reason GnuPG was asking for the dummy password, was
that this user was set as a signer in my context (as default). Now I use

gpgme_signers_clear(mContext);

before I encrypt/sign my string. The request for the dummy password 
disappeared. The only problem remaining is that the application still ignores 
my 
own password callback and uses the GnuPG default:

gpgme_set_passphrase_cb(mContext, passphrase_cb, nullptr);

I replaced my callback with your code:

gpgme_error_t passphrase_cb(void *hook, const char *uid_hint, const char 
*passphrase_info,
                            int prev_was_bad, int fd){
   
    std::string passphrase { "" };
    size_t written { 0 };
    std::cout << "Enter your passphrase: ";
    std::getline(std::cin, passphrase);

    if (passphrase.empty())
        return GPG_ERR_CANCELED;

    while (written < passphrase.size())
    {
        ssize_t bytesWritten = gpgme_io_write(fd,
                                              &passphrase[0] + written,
                passphrase.size() - written);
        if (bytesWritten == 0)
            break;
        written += bytesWritten;
    }
    gpgme_io_write(fd, "\n", 1);
    return GPG_ERR_NO_ERROR;
}
_______________________________________________
Gnupg-users mailing list
Gnupg-users@gnupg.org
http://lists.gnupg.org/mailman/listinfo/gnupg-users

Reply via email to