BUG python-gnupg error invalid recipient

Visto 552 veces
Saltar al primer mensaje no leído

Ian Stanley

no leída,
7 ago 2021, 2:00:427/8/21
a python-gnupg
I have been getting my hands dirty figuring out the python-gnupg module and am pleased that 

``` demogpg.py
import gnupg

gpg = gnupg.GPG(gnupghome='/home/ian/.gnupg')
print(gpg)
message = """
Copyright (c) 2021, Ian Stanley
All rights reserved.
"""

#recipients = 'myemail...@gmail.com'
recipients = 'test@noteslib'
data = gpg.encrypt(message, recipients)
print (data.ok)
print (data.status)
print (data)
checkmsg = gpg.decrypt(str(data))
print (checkmsg)
```

When I use the first line with the recipients = 'myemail...@gmail.com' the code runs fine. But when I use the second recipients line I get the following:
<gnupg.GPG object at 0x7fce49c6d040>
False
invalid recipient


Now GNUPG does not enforce a valid email address format (partly because top level domains seem to change each week these days ... but mainly because it is not a requirement of the application that the "email" address field is a valid email address.

A number of developers and sysadmins will create a user@hostname (not domain name) to a key for backup encryption.

The python-gnupg module appears to be validating whether the key is of the form user...@domain.tld  when it is not required by GNUPG. 

It is not required by GNUPG for one very good reason. Email can be sent between two unix-like systems whose ip address is in the hosts file. So you can use the mail program to email root@myserver and it works.

The test@noteslib key is a valid key. It works for encryption/decryption 

For me I can recreate the keys but you may find this breaking for other users.

I believe that the python-gnupg module should follow the gnupg behaviour 


Vinay Sajip

no leída,
7 ago 2021, 3:30:307/8/21
a python-gnupg
I can't reproduce these results - see my comments and updated test script on the issue you raised on BitBucket.

Vinay Sajip

no leída,
7 ago 2021, 5:24:307/8/21
a python-gnupg
Actually, I have reproduced your result by not having a key for test@noteslib - so I think this is the reason for your error, not any problem with python-gnupg checking for valid email addresses (it doesn't). I have made further comments on the BitBucket issue.
Responder a todos
Responder al autor
Reenviar
0 mensajes nuevos