geluk / pass-winmenu

An easy-to-use password manager for Windows, compatible with pass.
MIT License
385 stars 25 forks source link

Unable to decrypt #46

Closed Jomik closed 5 years ago

Jomik commented 5 years ago

It fails when decrypting, saying that I do not have a secret key with that ID. I do have that though.. :

$ gpg --list-secret-keys --keyid-format LONG
/c/Users/Jonas Damtoft/.gnupg/pubring.kbx
-----------------------------------------
sec   rsa4096/B41F1...... 2018-12-11 [SC]
      F135EB6.....
uid                 [ultimate] Jonas Holst Damtoft <jonasdamtoft@gmail.com>
ssb   rsa4096/F2C06EECAEDD5C9B 2018-12-11 [E]
ssb   rsa4096/27B5..... 2018-12-11 [A]
[12:51:12.746] [DBG] ------------------------------
[12:51:12.749] [DBG] Starting pass-winmenu v1.9
[12:51:12.749] [DBG] ------------------------------
[12:51:12.926] [DBG] Config reloading enabled
[12:51:12.926] [DBG] Attempting to detect the GPG installation directory
[12:51:12.927] [DBG] GPG executable found at the configured path. Assuming installation dir to be C:\Users\Jonas Damtoft\Downloads\pass-winmenu\lib\GnuPG\bin
[12:51:13.068] [DBG] Calling GPG with "--version"
[12:51:13.181] [DBG] Using GPG version gpg (GnuPG) 2.2.6
[12:51:13.189] [DBG] Calling GPG with "--list-secret-keys"
[12:54:53.583] [DBG] Calling GPG with "--decrypt "C:\Users\Jonas Damtoft\passwordstore\au.gpg""
[12:54:53.623] [DBG] [GPG]: [GNUPG:] ENC_TO F2C06EECAEDD5C9B 1 0
[12:54:53.623] [DBG] [GPG]: gpg: encrypted with RSA key, ID F2C06EECAEDD5C9B
[12:54:53.623] [DBG] [GPG]: [GNUPG:] NO_SECKEY F2C06EECAEDD5C9B
[12:54:53.623] [DBG] [GPG]: [GNUPG:] BEGIN_DECRYPTION
[12:54:53.623] [DBG] [GPG]: [GNUPG:] DECRYPTION_FAILED
[12:54:53.623] [DBG] [GPG]: gpg: decryption failed: No secret key
[12:54:53.623] [DBG] [GPG]: [GNUPG:] END_DECRYPTION
[12:54:53.623] [DBG] [GPG]: [GNUPG:] FAILURE gpg-exit 33554433
willpower232 commented 5 years ago

It looks like you're using cygwin or something along those lines for seeing which GPG keys you have?

If you try using windows command prompt and C:\Users\Jonas Damtoft\Downloads\pass-winmenu\lib\GnuPG\bin\gpg --list-secret-keys --keyid-format LONG or something like that, that would confirm whether they are available to pass-winmenu.

Jomik commented 5 years ago

Ooooooh. Right, that makes sense. I did realize that powershell couldn't find it either. I guess I'll just have to add it to your bundled one :+1:

I will update once I verify.

willpower232 commented 5 years ago

You might want to take a look at the YAML file, you can override the directory of the GPG keys in there if you need it.

geluk commented 5 years ago

If you want to try out some GPG commands from the same context as pass-winmenu to see whether the environment you're working with is configured correctly, you can right click the notification area icon and click Open Shell.

This will open a shell with the gpg command pre-aliased to the same gpg.exe and pointed at the same home directory as pass-winmenu will use when executing GPG commands. In that shell, you can then call gpg -K to see if GPG finds your private keys, and where it's looking for them.

It seems likely that in your case the gpg instance called by pass-winmenu is looking for your keys in the incorrect location (otherwise I would have expected it to print a [DBG] [GPG]: [GNUPG:] KEY_CONSIDERED [key ID]).

If you set the GNUPGHOME environment variable to the path where your GPG keys are, pass-winmenu should find them. As @willpower232 mentioned, you can also set the gnupghome-override configuration key to do the same thing.

Jomik commented 5 years ago

Perfect. I changed the gnupghome-override to match the gpg home that contained my secret key. Thank you :)