isislovecruft / python-gnupg

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

Update documentation for recv_keys #191

Closed andrewtchin closed 6 years ago

andrewtchin commented 7 years ago

Following the previous example did not correctly set the keyserver:

ipdb> key = gpg.recv_keys( '2071B08A33BD3F06', 'hkp://pgp.mit.edu')
INFO:Requesting keys from hkp://wwwkeys.pgp.net: 2071B08A33BD3F06 hkp://pgp.mit.edu
DEBUG:Got arg string: --keyserver hkp://wwwkeys.pgp.net
DEBUG:_make_filo(): Converted to reverse list: ['hkp://wwwkeys.pgp.net', '--keyserver']
DEBUG:Got arg: --keyserver
DEBUG:Got value: hkp://wwwkeys.pgp.net
DEBUG:Got groups: {'--keyserver': 'hkp://wwwkeys.pgp.net'}
DEBUG:Got host string for keyserver setting: 'wwwkeys.pgp.net'
DEBUG:Cleaned host string: 'wwwkeys.pgp.net'
DEBUG:Setting keyserver: hkp://wwwkeys.pgp.net
DEBUG:Appending option: --keyserver hkp://wwwkeys.pgp.net
DEBUG:Got arg string: --recv-keys 2071B08A33BD3F06 hkp://pgp.mit.edu
DEBUG:_make_filo(): Converted to reverse list: ['hkp://pgp.mit.edu', '2071B08A33BD3F06', '--recv-keys']
DEBUG:Got arg: --recv-keys
DEBUG:Got value: 2071B08A33BD3F06
DEBUG:Got value: hkp://pgp.mit.edu
DEBUG:Got groups: {'--recv-keys': '2071B08A33BD3F06 hkp://pgp.mit.edu'}
DEBUG:'--recv-keys hkp://pgp.mit.edu' not hex.
DEBUG:Appending option: --recv-keys 2071B08A33BD3F06
DEBUG:Sending command to GnuPG process:
['/usr/local/MacGPG2/bin/gpg2', '--no-options', '--no-emit-version', '--no-tty', '--status-fd', '2', '--homedir', 'doctests', '--no-default-keyring', '--keyring', 'doctests/pubring.gpg', '--secret-keyring', 'doctests/secring.gpg', '--keyserver', 'hkp://wwwkeys.pgp.net', '--recv-keys', '2071B08A33BD3F06']
DEBUG:stderr reader: <Thread(Thread-2251, initial daemon)>
DEBUG:stdout reader: <Thread(Thread-2252, initial daemon)>
DEBUG:Reading data from stream '<_io.BufferedReader name=24>'...
DEBUG:Finishing reading from stream '<_io.BufferedReader name=24>'...
DEBUG:Read    0 bytes total
DEBUG:recv_keys result: {'_gpg': <gnupg.gnupg.GPG object at 0x11056e898>, '_ok_reason': {'0': 'Not actually changed', '1': 'Entirely new key', '2': 'New user IDs', '4': 'New signatures', '8': 'New subkeys', '16': 'Contains private key', '17': 'Contains private key'}, '_problem_reason': {'0': 'No specific reason given', '1': 'Invalid Certificate', '2': 'Issuer Certificate missing', '3': 'Certificate Chain too long', '4': 'Error storing certificate'}, '_fields': ['count', 'no_user_id', 'imported', 'imported_rsa', 'unchanged', 'n_uids', 'n_subk', 'n_sigs', 'n_revoc', 'sec_read', 'sec_imported', 'sec_dups', 'not_imported'], 'counts': OrderedDict([('count', 1), ('no_user_id', 0), ('imported', 0), ('imported_rsa', 0), ('unchanged', 1), ('n_uids', 0), ('n_subk', 0), ('n_sigs', 0), ('n_revoc', 0), ('sec_read', 0), ('sec_imported', 0), ('sec_dups', 0), ('not_imported', 0)]), 'fingerprints': ['031EC2536E580D8EA286A9F22071B08A33BD3F06'], 'results': [{'fingerprint': '031EC2536E580D8EA286A9F22071B08A33BD3F06', 'status': 'Not actually changed\n'}], 'stderr': 'gpg: requesting key 33BD3F06 from hkp server wwwkeys.pgp.net\n[GNUPG:] IMPORT_OK 0 031EC2536E580D8EA286A9F22071B08A33BD3F06\ngpg: key 33BD3F06: "NIIBE Yutaka (GnuPG Release Key) <gniibe@fsij.org>" not changed\ngpg: Total number processed: 1\ngpg:              unchanged: 1\n[GNUPG:] IMPORT_RES 1 0 0 0 1 0 0 0 0 0 0 0 0 0\n', 'data': b''}

Updated version uses keyserver correctly:

ipdb> key = gpg.recv_keys( '2071B08A33BD3F06', keyserver='hkp://pgp.mit.edu')
INFO:Requesting keys from hkp://pgp.mit.edu: 2071B08A33BD3F06
DEBUG:Got arg string: --keyserver hkp://pgp.mit.edu
DEBUG:_make_filo(): Converted to reverse list: ['hkp://pgp.mit.edu', '--keyserver']
DEBUG:Got arg: --keyserver
DEBUG:Got value: hkp://pgp.mit.edu
DEBUG:Got groups: {'--keyserver': 'hkp://pgp.mit.edu'}
DEBUG:Got host string for keyserver setting: 'pgp.mit.edu'
DEBUG:Cleaned host string: 'pgp.mit.edu'
DEBUG:Setting keyserver: hkp://pgp.mit.edu
DEBUG:Appending option: --keyserver hkp://pgp.mit.edu
DEBUG:Got arg string: --recv-keys 2071B08A33BD3F06
DEBUG:_make_filo(): Converted to reverse list: ['2071B08A33BD3F06', '--recv-keys']
DEBUG:Got arg: --recv-keys
DEBUG:Got value: 2071B08A33BD3F06
DEBUG:Got groups: {'--recv-keys': '2071B08A33BD3F06'}
DEBUG:Appending option: --recv-keys 2071B08A33BD3F06
DEBUG:Sending command to GnuPG process:
['/usr/local/MacGPG2/bin/gpg2', '--no-options', '--no-emit-version', '--no-tty', '--status-fd', '2', '--homedir', 'doctests', '--no-default-keyring', '--keyring', 'doctests/pubring.gpg', '--secret-keyring', 'doctests/secring.gpg', '--keyserver', 'hkp://pgp.mit.edu', '--recv-keys', '2071B08A33BD3F06']
DEBUG:stderr reader: <Thread(Thread-2417, initial daemon)>
DEBUG:stdout reader: <Thread(Thread-2418, initial daemon)>
DEBUG:Reading data from stream '<_io.BufferedReader name=24>'...
DEBUG:Finishing reading from stream '<_io.BufferedReader name=24>'...
DEBUG:Read    0 bytes total
DEBUG:recv_keys result: {'_gpg': <gnupg.gnupg.GPG object at 0x11056e898>, '_ok_reason': {'0': 'Not actually changed', '1': 'Entirely new key', '2': 'New user IDs', '4': 'New signatures', '8': 'New subkeys', '16': 'Contains private key', '17': 'Contains private key'}, '_problem_reason': {'0': 'No specific reason given', '1': 'Invalid Certificate', '2': 'Issuer Certificate missing', '3': 'Certificate Chain too long', '4': 'Error storing certificate'}, '_fields': ['count', 'no_user_id', 'imported', 'imported_rsa', 'unchanged', 'n_uids', 'n_subk', 'n_sigs', 'n_revoc', 'sec_read', 'sec_imported', 'sec_dups', 'not_imported'], 'counts': OrderedDict([('count', 1), ('no_user_id', 0), ('imported', 0), ('imported_rsa', 0), ('unchanged', 1), ('n_uids', 0), ('n_subk', 0), ('n_sigs', 0), ('n_revoc', 0), ('sec_read', 0), ('sec_imported', 0), ('sec_dups', 0), ('not_imported', 0)]), 'fingerprints': ['031EC2536E580D8EA286A9F22071B08A33BD3F06'], 'results': [{'fingerprint': '031EC2536E580D8EA286A9F22071B08A33BD3F06', 'status': 'Not actually changed\n'}], 'stderr': 'gpg: requesting key 33BD3F06 from hkp server pgp.mit.edu\n[GNUPG:] IMPORT_OK 0 031EC2536E580D8EA286A9F22071B08A33BD3F06\ngpg: key 33BD3F06: "NIIBE Yutaka (GnuPG Release Key) <gniibe@fsij.org>" not changed\ngpg: Total number processed: 1\ngpg:              unchanged: 1\n[GNUPG:] IMPORT_RES 1 0 0 0 1 0 0 0 0 0 0 0 0 0\n', 'data': b''}
isislovecruft commented 6 years ago

@andrewtchin I guess you must have deleted your repo on Github? I recreated your patch and committed it with GIT_AUTHOR_NAME="Andrew Chin" so that you'll still get the credit.

This will be in 3.0.2. Thanks again!