Ensuring that when a passphrase is passed in, it is returned as a string from the passphrase callback.

This commit is contained in:
Gareth J. Greenaway 2018-06-04 16:00:07 -07:00 committed by rallytime
parent 9c964fdbce
commit 329b2e5956
No known key found for this signature in database
GPG key ID: E8F1A4B90D0DEA19
2 changed files with 12 additions and 1 deletions

View file

@ -376,7 +376,7 @@ def _passphrase_callback(passphrase):
Returns a callback function used to supply a passphrase for private keys
'''
def f(*args):
return passphrase
return salt.utils.stringutils.to_str(passphrase)
return f
@ -840,6 +840,7 @@ def create_private_key(path=None,
bio = M2Crypto.BIO.MemoryBuffer()
if passphrase is None:
cipher = None
rsa.save_key_bio(
bio,
cipher=cipher,

View file

@ -164,3 +164,13 @@ c9bcgp7D7xD+TxWWNj4CSXEccJgGr91StV+gFg4ARQ==
days_valid=3650,
days_remaining=0)
self.assertIn(b'BEGIN CERTIFICATE', ret)
@skipIf(not HAS_M2CRYPTO, 'Skipping, M2Crypt is unavailble')
def test_create_key(self):
'''
Test that x509.create_key returns a private key
:return:
'''
ret = x509.create_private_key(text=True,
passphrase='super_secret_passphrase')
self.assertIn(b'BEGIN RSA PRIVATE KEY', ret)