Unusable public key when encrypt after import

3,481 views
Skip to first unread message

Martin

unread,
Oct 31, 2011, 2:46:38 PM10/31/11
to python-gnupg
Hi people, I have a problem to encrypt a file.
I've a script that done all this steps:

1. Import a public key from a file. OK
2. Encrypt file with fingerprint of that imported key. ERROR
3. I receive a error message in debug log file telling:

[gnupg] gpg --status-fd 2 --no-tty --encrypt --recipient
"77356D2E2F4751C29E8B966E2827360F7441CD74" --armor --output "upload
\test1_encrypted.txt" --always-trust
[gnupg] data copier: <Thread(Thread-11, initial daemon)>, <open file
'upload\test1.txt', mode 'rb' at 0x028EADE0>, <open file '<fdopen>',
mode 'wb' at 0x028EAE38>
[gnupg] sending chunk (16): 'OLS Upload Test1'
[gnupg] closed output, 16 bytes sent
[gnupg] stderr reader: <Thread(Thread-12, initial daemon)>
[gnupg] stdout reader: <Thread(Thread-13, initial daemon)>
[gnupg] gpg: 77356D2E2F4751C29E8B966E2827360F7441CD74: omitido:
Unusable public key
[gnupg] [GNUPG:] INV_RECP 0 77356D2E2F4751C29E8B966E2827360F7441CD74
[gnupg] gpg: [stdin]: encryption failed: Unusable public key
[gnupg] encrypt result: ''

How can I programmatically trust a key? Is that the problem?

Regards

martin

Vinay Sajip

unread,
Oct 31, 2011, 3:07:12 PM10/31/11
to python-gnupg

On Oct 31, 6:46 pm, Martin <mugui...@gmail.com> wrote:
> Unusable public key
> [gnupg] [GNUPG:] INV_RECP 0 77356D2E2F4751C29E8B966E2827360F7441CD74
> [gnupg] gpg: [stdin]: encryption failed: Unusable public key
> [gnupg] encrypt result: ''
>
> How can I programmatically trust a key? Is that the problem?

It might be - unfortunately GnuPG doesn't say, the "0" after INV_RECP
is unhelpfully "No specific reason given". At the moment you can't set
the trust programmatically on a key using python-gnupg because it's an
interactive edit-key operation, but you should be able to subclass the
GPG class and add an "--always-trust" argument to the args sent to
gpg.

Regards,

Vinay Sajip

Martin

unread,
Oct 31, 2011, 3:14:22 PM10/31/11
to python-gnupg
Thanks for the quick response!

I've added --always-trust argument when call encrypt.

[gnupg] gpg --status-fd 2 --no-tty --encrypt --recipient
"77356D2E2F4751C29E8B966E2827360F7441CD74" --armor --output "upload
\test1_encrypted.txt" --always-trust

and that doesn't work.

Are you refering to that?

Thanks in advance

Vinay Sajip

unread,
Oct 31, 2011, 3:29:41 PM10/31/11
to python-gnupg


On Oct 31, 7:14 pm, Martin <mugui...@gmail.com> wrote:
> I've added --always-trust argument when call encrypt.
>
> [gnupg] gpg --status-fd 2 --no-tty --encrypt --recipient
> "77356D2E2F4751C29E8B966E2827360F7441CD74" --armor --output "upload
> \test1_encrypted.txt" --always-trust
>
> and that doesn't work.
>
> Are you refering to that?
>

Yes. If it's not a trust issue, perhaps there's something else not
right with the key. Did you double check the log messages during
import to ensure that everything was as expected?

Regards,

Vinay Sajip
Reply all
Reply to author
Forward
0 new messages