isislovecruft / python-gnupg

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

Unable to Decrypt File #195

Open joshuamcginnis opened 7 years ago

joshuamcginnis commented 7 years ago

Since updating to GPG2, I've been unable to successfully decrypt a symmetrically encrypted file using this library.

import gnupg

gpg = gnupg.GPG(homedir='~/.gnupg')
encrypted_file = '/path/to/file.gpg'
passphrase = 'my_passphrase'
output = 'output.txt'

with open(encrypted_file, 'rb') as input_file:
    result = gpg.decrypt_file(
        filename=input_file,
        passphrase=passphrase,
        output=destination
    )

    print('RESULT', result.status)
    print('RESULT', result.data)
    print('RESULT', result.valid)
2017-06-07 11:37:03,339 - gnupg - WARNING - Ignoring '/usr/local/bin/gpg' (path is a symlink)
2017-06-07 11:37:03,340 - gnupg - ERROR - Could not find binary for 'gpg'.
2017-06-07 11:37:03,340 - gnupg - INFO - Setting homedir to '/Users/joshuamcginnis/.gnupg'
2017-06-07 11:37:03,366 - gnupg - INFO - 
Initialised settings:
binary: /usr/local/bin/gpg2
binary version: 2.1.21
homedir: /Users/joshuamcginnis/.gnupg
ignore_homedir_permissions: False
keyring: /Users/joshuamcginnis/.gnupg/pubring.gpg
secring: /Users/joshuamcginnis/.gnupg/secring.gpg
default_preference_list: SHA512 SHA384 SHA256 AES256 CAMELLIA256 TWOFISH AES192 ZLIB ZIP Uncompressed
keyserver: hkp://wwwkeys.pgp.net
options: None
verbose: False
use_agent: False

Exception in thread Thread-2:
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 810, in __bootstrap_inner
    self.run()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 763, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/Users/joshuamcginnis/.virtualenvs/darwin/lib/python2.7/site-packages/gnupg/_meta.py", line 648, in _read_response
    result._handle_status(keyword, value)
  File "/Users/joshuamcginnis/.virtualenvs/darwin/lib/python2.7/site-packages/gnupg/_parsers.py", line 1627, in _handle_status
    super(Crypt, self)._handle_status(key, value)
  File "/Users/joshuamcginnis/.virtualenvs/darwin/lib/python2.7/site-packages/gnupg/_parsers.py", line 1540, in _handle_status
    raise ValueError("Unknown status message: %r" % key)
ValueError: Unknown status message: u'KEY_CONSIDERED'

('RESULT', None)
('RESULT', '')
('RESULT', False)

Is there a workaround? Perhaps downgrade to 1.x?