isislovecruft / python-gnupg

A modified version of python-gnupg, including security patches, extensive documentation, and extra features.
Other
424 stars 172 forks source link

(windows), recv_keys not working #227

Closed aventrax closed 6 years ago

aventrax commented 6 years ago

Hello, I'm trying to simply retrieve a public key from a key server, but the same code fails on windows and works on linux. Can you help me?

The code is here:


gpg = gnupg.GPG(binary='C:/Progra~2/GnuPG/bin/gpg.exe', homedir='C:/temp')
#gpg = gnupg.GPG() #on linux I use this
key = gpg.recv_keys('XXXXXXX', keyserver='hkp://pgp.mit.edu')

On windows, the last line produces an error that I'm not able to understand:

  File "C:\Program Files\Python36\lib\threading.py", line 916, in _bootstrap_inner
    self.run()
  File "C:\Program Files\Python36\lib\threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Program Files\Python36\lib\site-packages\gnupg\_meta.py", line 650, in _read_response
    result._handle_status(keyword, value)
  File "C:\Program Files\Python36\lib\site-packages\gnupg\_parsers.py", line 1294, in _handle_status
    raise ValueError("Unknown status message: %r" % key)
ValueError: Unknown status message: 'FAILURE'

Windows 10: Python 3.6.3 (python-gnupg: 2.3.1) GnuPG 2.1.15 (tried 2.2.5, same result)

Ubuntu 16.04: Python 3.5.2 (python-gnupg: 2.3.1) GnuPG 2.1.11

Any help?

aventrax commented 6 years ago

Issue solved simply initializing the C:\temp directory with gpg.exe:

set GNUPGHOME=C:\temp
gpg -k
gpg: keybox 'C:/temp/pubring.kbx' created
gpg: C:/temp/trustdb.gpg: trustdb created

After that, the python script worked.