Commit 3d668b49 authored by ale's avatar ale

Add a new credential type 'rsakey' (a PEM-encoded RSA private key)

parent 8e9e871e
Pipeline #2569 failed with stage
in 1 minute and 18 seconds
......@@ -118,6 +118,14 @@ def generate_tsig_key():
shutil.rmtree(tmp_dir, ignore_errors=True)
def generate_rsa_key(bits):
"""Create a RSA private key of the specified size.
The result is a PEM-encoded string.
"""
return subprocess.check_output(['openssl', 'genrsa', str(bits)])
def generate_password(entry):
ptype = entry.get('type', 'simple')
if ptype == 'simple':
......@@ -126,6 +134,8 @@ def generate_password(entry):
return generate_binary_secret(length=int(entry.get('length', 32)))
elif ptype == 'tsig':
return generate_tsig_key()
elif ptype == 'rsakey':
return generate_rsa_key(bits=int(entry.get('bits', 2048)))
else:
raise Exception('Unknown password type "%s"' % ptype)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment