Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't sign (at all) #122

Closed
ghost opened this issue Sep 29, 2015 · 6 comments
Closed

Can't sign (at all) #122

ghost opened this issue Sep 29, 2015 · 6 comments
Assignees

Comments

@ghost
Copy link

ghost commented Sep 29, 2015

[bts@workhorse tmp]$ echo 'this is a testfile.' > testfile
import gnupg

gpg=gnupg.GPG(homedir='/home/bts/.gnupg')
file=open('testfile','r')

sig=gpg.sign(file.read())

yields:

Exception in thread Thread-2:
Traceback (most recent call last):
  File "/usr/lib/python3.4/threading.py", line 920, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.4/threading.py", line 868, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/lib/python3.4/site-packages/gnupg/_meta.py", line 626, in _read_response
    result._handle_status(keyword, value)
  File "/usr/lib/python3.4/site-packages/gnupg/_parsers.py", line 955, in _handle_status
    raise ValueError("Unknown status message: %r" % key)
ValueError: Unknown status message: 'FAILURE'

Using python 3.4.3.

I get the same when using Python 2.7.10:

Exception in thread Thread-2:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 763, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/usr/lib/python2.7/site-packages/gnupg/_meta.py", line 624, in _read_response
    result._handle_status(keyword, value)
  File "/usr/lib/python2.7/site-packages/gnupg/_parsers.py", line 955, in _handle_status
    raise ValueError("Unknown status message: %r" % key)
ValueError: Unknown status message: u'FAILURE'

Using python-gnupg ver. 2.0.2 on 3.4.3 and 2.0.1 on 2.7.10, via Arch's AUR (you can view the packaging process here: https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=python-gnupg-isis and https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=python2-gnupg-isis, for python 3 and python 2 respectively).

@ghost
Copy link
Author

ghost commented Sep 29, 2015

I'm wondering if the version distributed is just too old.

When running the same exact sequence as listed on this projects readme:

#!/usr/bin/env python3

import gnupg

gpg = gnupg.GPG(binary='/usr/bin/gpg',
    homedir='./keys',
    keyring='pubring.gpg',
    secring='secring.gpg')

batch_key_input = gpg.gen_key_input(
    key_type='RSA',
    key_length=4096)

print(batch_key_input)

key = gpg.gen_key(batch_key_input)
print(key.fingerprint)

I get the following:

Key-Type: RSA
Key-Length: 4096
Name-Real: Autogenerated Key
Expire-Date: 2016-09-29
Name-Email: devtestuser@workhorse
%commit

Exception in thread Thread-3:
Traceback (most recent call last):
  File "/usr/lib/python3.4/threading.py", line 920, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.4/threading.py", line 868, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/lib/python3.4/site-packages/gnupg/_meta.py", line 626, in _read_response
    result._handle_status(keyword, value)
  File "/usr/lib/python3.4/site-packages/gnupg/_parsers.py", line 866, in _handle_status
    raise ValueError("Unknown status message: %r" % key)
ValueError: Unknown status message: 'PINENTRY_LAUNCHED'

None

i'll try from git.

@ghost
Copy link
Author

ghost commented Sep 29, 2015

and from git (at least in virtualenv) gives the same.

@meskio
Copy link
Collaborator

meskio commented May 18, 2016

I think this is related to gpg2, I'm seeing similar issues.

It looks like is the same than #137

@isislovecruft
Copy link
Owner

@Bts368 Thanks for reporting this!

@meskio Yes, I think this is solved by doing what @dmarsic did in #137 (i.e. putting allow-loopback-pinentry into ~/.gnupg/gpg-agent.conf and restarting the gpg-agent process).

I'll guess I'll add a handler for PINENTRY_LAUNCHED which explains this in a log.error() message. Better ideas welcome.

@isislovecruft
Copy link
Owner

@Bts368 Also, the reason this is happening in your case is that you've configured a pinentry program, and you didn't supply a passphrase= parameter to gen_key_input(). Try supplying the passphrase, so that it doesn't try to get it from pinentry.

isislovecruft added a commit that referenced this issue Dec 21, 2016
@isislovecruft isislovecruft self-assigned this Dec 21, 2016
@isislovecruft
Copy link
Owner

This should be fixed in 2.2.0, which also includes the fix for #137.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants