Bug 319120 - When i try to open an encrypted .kmy file the program does not ask me the passphrase and then prompt "could not open the file <filename>: bad passphrase"
Summary: When i try to open an encrypted .kmy file the program does not ask me the pas...
Status: RESOLVED WORKSFORME
Alias: None
Product: kmymoney
Classification: Applications
Component: general (show other bugs)
Version: 4.6.3
Platform: Ubuntu Linux
: NOR major
Target Milestone: ---
Assignee: KMyMoney Devel Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-04-30 14:38 UTC by Emanuele Andreola
Modified: 2014-01-25 15:54 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Emanuele Andreola 2013-04-30 14:38:14 UTC
The encryption is working fine but the decryprion doesn't. Somehow KMyMoney doesn't ask for the passphrase to decrypt the file.


Reproducible: Always




I red that some other people had the same problem, but the solution(s) does not work for me.
I checked my gpg, gpg-agent and pinetry-qt installation and it seems allright (all packages are up-tp-date). 
I've also installed Kgpg to menage my keys with ease.
The only strange thing is that in the gpg.conf file in /home/<myhomename>/.gnupg is written only: # GnuPG config file created by KGpg
Comment 1 Jack 2013-04-30 14:53:56 UTC
Can you manually decrypt the file?

I'm not sure gpg.conf needs much content - mine has only two keyserver lines and one keyserver-options line.
Comment 2 Emanuele Andreola 2013-04-30 18:29:56 UTC
Thanks for your timely reply, Jack

I just tried to decrypt the file with gpg using the konsole, it worked. I also opened the decrypted file with KMyMoney and i had no problems, no data loss or anything strange.

I probably miss something, 'cause everything else seems to work pretty good...
Comment 3 Emanuele Andreola 2013-04-30 18:39:13 UTC
Update:

I just encrypted a non-encrypted .kmy file with gpg through the command line and tried to open it with kmymoney. It still prompts the bad passphrase error.
Comment 4 Jack 2013-04-30 18:44:53 UTC
I don't use encryption, so I can't really test, but it sounds like a problem with one of the gpg helper apps or configuration.  It seems like KMM thinks it either knows the passphrase or can get it from somewhere without prompting you, but it obviously can not.  Do you have any other applications that can use gpg? Do they prompt for the passphrase?  (perhaps email?)
Comment 5 Emanuele Andreola 2013-04-30 18:56:03 UTC
I used to sign my e-mails with a gpg related signature, but it's long i don't do it now. I actually created the gpg key just for kmymoney. Now i'll try to use gpg with some other program.

I tried to close the wallet (kdewallet) to see if kmm asks me to open it when opening the file, but it doesn't, and the same error pops up...
Comment 6 Emanuele Andreola 2013-04-30 19:09:39 UTC
Update:
Just sent my .kmy encrypted file to a diffent computer just to see what happens. when i tried to open it kmm says that it cannot decrypt the file, but it prompted a diffent error window that in my pc.
Both computers have kubuntu 13.04 installed, all packages up-to-date.
Comment 7 allan 2013-04-30 21:20:32 UTC
See if this helps -
http://mail.kde.org/pipermail/kmymoney-devel/2010-March/001096.html
Comment 8 Emanuele Andreola 2013-04-30 22:03:41 UTC
After some googling and thinking i was close to give up, then i tried to run the same command of the guy you linked:
input:
gpg --use-agent --no-tty --sign
output:
gpg: gpg-agent non è disponibile in questa sessione
gpg: Sorry, no terminal at all requested - can't get input

the first line says that gpg-agent is not available in (maybe "for") this session, so maybe it's a gpg-agent misconfiguration error
Comment 9 allan 2013-04-30 22:54:23 UTC
For that error, I find -
> gpg: Sorry, no terminal at all requested - can't get input

Remove the line
no-tty
from ~/.gnupg/gpg.conf or ~/.gnupg/options

Don't know if you tried that.  If still not right, try substituting '--batch'.
Comment 10 Emanuele Andreola 2013-04-30 23:06:25 UTC
My ~/.gnupg/gpg.conf file is empty, there's just a comment about Kgpg, nothing else.
trying:
gpg --use-agent --batch --sign
i get:
gpg: Passphrase non valida; riprova ...  
gpg: can't query passphrase in batch mode
gpg: no default secret key: passphrase errata
gpg: signing failed: passphrase errata

first and last mean "bad passphrase"
Comment 11 Thomas Baumgart 2013-05-02 06:56:18 UTC
To me this looks like the gpg-agent is not running. You can check that with the following command (includes my output here):

thb@thb-nb:~> ps ax | grep gpg-agent
 1596 ?        Ss     0:17 gpg-agent --daemon
 9868 pts/9    S+     0:00 grep --color=auto gpg-agent
12324 ?        Ss     0:08 /usr/bin/gpg-agent --sh --daemon --write-env-file /ho
12353 ?        Ss     0:07 gpg-agent --daemon

If it does not run, then you need to start it during KDE startup. You can do that by adding the following one-liner to ~/.kde[4]/env/gpg-agent.sh  (the filename must end in .sh to be picked up by KDE) and make that file executable:

eval "$(gpg-agent --daemon)"

After that change you will have to logout of your KDE session and log back in to execute it once.
Comment 12 Emanuele Andreola 2013-05-02 13:01:36 UTC
Hi,

if i run: 
ps ax | grep gpg-agent 
my output is:
2771 pts/3    S+     0:00 grep --color=auto gpg-agent
an nothing else (my output may be wrong, i'm a command-line newbie)

anyway, in my ~/.kde[4]/env directory i've no gpg-agent files.

Today i tried to use kmm with encryption in a different pc and it worked (even if i've the same linux dristro/updates/programs...). 
Maybe it's beacuse i use two different partitions for my home and /, and i formatted my home partition last time something like 2 years ago. maybe it's just some strange corrupted setting saved in my /home....i'll try to wipe out all the disk and reinstall everything...
Comment 13 allan 2013-05-02 13:22:45 UTC
On Thu, 02 May 2013 13:01:36 +0000
Emanuele Andreola <emanuele.andreola@gmail.com> wrote:

> https://bugs.kde.org/show_bug.cgi?id=319120
> 
> --- Comment #12 from Emanuele Andreola <emanuele.andreola@gmail.com>
> --- Hi,
> 
> if i run: 
> ps ax | grep gpg-agent 
> my output is:
> 2771 pts/3    S+     0:00 grep --color=auto gpg-agent
> an nothing else (my output may be wrong, i'm a command-line newbie)
> 
> anyway, in my ~/.kde[4]/env directory i've no gpg-agent files.
> 
> Today i tried to use kmm with encryption in a different pc and it
> worked (even if i've the same linux dristro/updates/programs...). 
> Maybe it's beacuse i use two different partitions for my home and /,
> and i formatted my home partition last time something like 2 years
> ago. maybe it's just some strange corrupted setting saved in
> my /home....i'll try to wipe out all the disk and reinstall
> everything...
> 


If it's not too late to stop you doing that, can you check if
gpg-agent/gnupg -agentis installed.
Comment 14 Emanuele Andreola 2013-05-02 13:28:18 UTC
well, if i type:
gpg-agent/gnupg -agentis installed
it says
bash: gpg-agent/gnupg: File o directory non esistente (not existing)

Anyway when i check
sudo apt-get install gnupg-agent
it says that gnupg-agent is installed and up-to-date, same output for pinentry-qt4
Comment 15 allan 2013-05-02 16:52:11 UTC
On Thu, 02 May 2013 13:28:18 +0000
Emanuele Andreola <emanuele.andreola@gmail.com> wrote:

> https://bugs.kde.org/show_bug.cgi?id=319120
> 
> --- Comment #14 from Emanuele Andreola <emanuele.andreola@gmail.com>
> --- well, if i type:
> gpg-agent/gnupg -agentis installed
> it says
> bash: gpg-agent/gnupg: File o directory non esistente (not existing)
> 
> Anyway when i check
> sudo apt-get install gnupg-agent
> it says that gnupg-agent is installed and up-to-date, same output for
> pinentry-qt4
> 

OK, now you need to get it running, this first time.

From Thomas -
"
If it does not run, then you need to start it during KDE startup. You can do
that by adding the following one-liner to ~/.kde[4]/env/gpg-agent.sh  (the
filename must end in .sh to be picked up by KDE) and make that file executable:

eval "$(gpg-agent --daemon)"

After that change you will have to logout of your KDE session and log back in
to execute it once."

But, you say you don't have gpg-agent.sh.  I found an example in 
http://userbase.kde.org/KMail/PGP_MIME/en, although, possibly a typo,
it calls it gpgagent.sh .  There are some other tips there that may be
useful.

Allan
Comment 16 Thomas Baumgart 2013-05-03 12:07:41 UTC
Hm, I thought it would be clear from what I wrote that if you don't have the file, you need to create it and simply add that one magic line to it and make it executable. Why didn't you do that? There's certainly no need to wipe out the whole disk (we're not on that other OS). You mentioned, that you have the agent, and even the pinentry-qt program is available. All you need to do is get the agent running and the method I use is the small shell script in .kde/env

@Allen: the name of the script does not matter. you can call it whatever you like. It only needs to end in .sh (that's "dot s h") and it must be executable.
Comment 17 Emanuele Andreola 2013-05-05 15:47:36 UTC
Sorry for the delay,
I just solved it, well, I didn't actually solved it, kind of...
As I said before I formatted the whole disk, put all my data back into it, installed all the programs i need and rebooted. Now it works.
So i didn't really find out what was the problem, but it seems like it's gone with the formatting.

@Thomas: before doing what i did i tried your way; it actually pops up the instert-key window, but i wasn't able to type anything into it, and after a few seconds it "disappears" like as if i pressed enter (even if i didn't press any keys).

So, well, thank you all for your kind support, you showed up the best of the open-source community: cooperation.
Comment 18 Cristian Oneț 2013-08-28 05:48:35 UTC
Closing this since it has been reported as fixed.
Comment 19 raphagonz 2014-01-25 15:54:13 UTC
Hi,
Sorry to come back on this subject

I have exactly the same things :
- KMM not asking for a passphrase 
- ps -ef |grep gpg  finding gpg-agent --daemon
- decrypt file from console ok (and opening the decrypted file in KMM ok)

It was working fine before and I have the problem only since I upgraded to Lubuntu 13.10

Thanks for your help

Raphael