Closed joshuamcginnis closed 7 years ago
Fixed by reading the key contents and passing it to import_keys:
result = gpg.import_keys(open(private_key, 'rb').read())
I am having the same issue. while looking into the code I don't thin it is possible to import a key using passpharse, because the passpharse is set to False
by default.
The _handle_io
:
def _handle_io(self, args, file, result, passphrase=False, binary=False):
called from import_keys(self, key_data)
is called in this fashion:
self._handle_io(['--import'], data, result, binary=True)
I don't see a way to pass passphase there.
When I 'hard-code' the passphasee into the self._handle_io(['--import'], data, result, passphrase='secret', binary=True)
It works as expected. I think there should be a posibility to pass passpharse as an argument into GPG.import_keys()
Using @pajuscz 's suggestion, I provided the solution for importing keys with passphrases on #284 .
Add passphrase=False
to def import_keys(...)
and then provide passphrase
to self._handle_io(['--import'], data, result, passphrase, binary=True)
.
If you provide no passphrase to import_keys()
, it should default to False which is already the default for _handle_io(...)
under _utils.py
, else you can provide the passphrase of the key.
I confirmed this was working, although I did need to make some squirrel patches to my _parsers.py for some unknown status errors.
I'm able to import a private key with passphrase like so:
But I am unable to import a private key with a symmetric passphrase using this lib:
What is the correct way to import this private key?