KMail Trunk: Signing

By randomguy3

If, like me, you run KMail trunk (what will be 4.2), sign your emails and don’t use gpg-agent, you may have found that signing emails suddenly stopped working a while back.  I finally traced the problem: a change in the way signing is done with the gpgme backend means that kleo, the magic behind all things cryptographic in kdepim, no longer provides a password entry dialog.  The reason is that the signing is done in a side thread, and GUI stuff can only be done in the main thread.

The solution?  Use gpg-agent, of course.  You need to install gpg-agent and the pinentry package, and then put a script (call it gpg-agent.sh – the .sh is important) in $KDEHOME/env that starts gpg-agent.  The contents of my ~/.kde/env/gpg-agent.sh file are simply:

eval $(gpg-agent --daemon --pinentry-program /usr/bin/pinentry-qt)

You should also stop it again at logout.  To do this put the following script in the $KDEHOME/shutdown folder and make it executable:

!/bin/sh
# the second field of the GPG_AGENT_INFO variable is the
# process ID of the gpg-agent active in the current session
# so we'll just kill that, rather than all of them
[ -n "${GPG_AGENT_INFO}" ] &&
    kill $(echo "${GPG_AGENT_INFO}" | cut -d ':' -f 2)

All this stolen from a Gentoo HOWTO.

6 Responses to “KMail Trunk: Signing”

  1. Jucato Says:

    Thank you very much! This just made my day! I have been at a loss trying to figure out how to get my e-mails signed using KMail (in 4.1). Thank you again! :)

  2. مهرداد Says:

    but it don’t working for me! :(
    i’m using kmail 1.10.1 on KDE 4.1.2 on Kubuntu

  3. مهرداد Says:

    :) it works…

  4. حل مشکل امضای ایمیل با Kmail جدید (KDE4.1) « MGroup Says:

    [...] مطلب از اینجا دزدیده [...]

  5. Cassiano Bertol Leal Says:

    Thanks, it works!

    You just forgot to mention that gpg-agent.sh should also be made executable. ;)

  6. Martin Says:

    Great workaround, however it was not working out of the box for me on archlinux with kdemod 4.3 and kmail 1.12.2. The reason was qt3 was missing. After installing qt3 it works.
    So if this workaround is not working for you I suggest to start pinentry-qt from a terminal and look at the output. If something like “error while loading shared libraries: libqt-mt.so.3: cannot open shared object file: No such file or directory” shows up it is likely that qt3 is missing.

Leave a Reply