5

I'm trying to init gpg like so:

BIN = C:/cygwin64/bin/gpg.exe
HOME = C:/cygwin64/home/Administrator/.gnupg    
gpg = gnupg.GPG(binary=BIN, homedir=HOME)

My key rings are located in C:/cygwin64/home/Administrator/.gnupg but whenever I use the list_keys commands:

public_keys = gpg.list_keys()
private_keys = gpg.list_keys(True)
print ('public keys:')
print(public_keys)
print ('private keys:')
print(private_keys)

it outputs me empty empty arrays.

So I tried to specify specific paths for rings this way:

 gpg = gnupg.GPG(binary=BIN, homedir=HOME, ignore_homedir_permissions=True,
                    keyring='C:/cygwin64/home/Administrator/.gnupg/secring.gpg',
                    secring='C:/cygwin64/home/Administrator/.gnupg/pubring.gpg')

same error.

Here are the errors I get whenever I try to decrypt a file:

stderr:  gpg: WARNING: unsafe permissions on homedir `C:/cygwin64/home/Administrator/.gnupg'
gpg: invalid key resource URL `C:/cygwin64/home/Administrator/.gnupg/pubring.gpg'
gpg: keyblock resource `(null)': general error
gpg: invalid key resource URL `C:/cygwin64/home/Administrator/.gnupg/secring.gpg'
gpg: keyblock resource `(null)': general error
gpg: no valid OpenPGP data found.
[GNUPG:] NODATA 1
[GNUPG:] NODATA 2
gpg: decrypt_message failed: eof

What am I missing?

Baptiste Arnaud
  • 2,522
  • 3
  • 25
  • 55
  • Does it work when calling gpg directly? These errors come straight from gpg, so Python might not be at fault here. – Norrius Jun 04 '18 at 19:39
  • It works when calling gpg directly. The python package doesn't recognize my key rings and does nothing when I try to import keys. So it surely comes from the package. I'll try to reinstall it. – Baptiste Arnaud Jun 05 '18 at 07:18

0 Answers0