Commit 76e8ef8a authored by Tom Mitchell's avatar Tom Mitchell
Browse files

Make passphrase file optional in protogeni test scripts.

Passphrase file is used if it exists and is readable. If passphrase
file does not exist or is not readable, invoke standard M2Crypto
passphrase callback to prompt user for passphrase.
parent 2a63abab
......@@ -137,9 +137,28 @@ def Fatal(message):
sys.exit(1)
def PassPhraseCB(v, prompt1='Enter passphrase:', prompt2='Verify passphrase:'):
passphrase = open(PASSPHRASEFILE).readline()
passphrase = passphrase.strip()
return passphrase
"""Acquire the encrypted certificate passphrase by reading a file
or prompting the user.
This is an M2Crypto callback. If the passphrase file exists and is
readable, use it. If the passphrase file does not exist or is not
readable, delegate to the standard M2Crypto passphrase
callback. Return the passphrase.
"""
if os.path.exists(PASSPHRASEFILE):
try:
passphrase = open(PASSPHRASEFILE).readline()
passphrase = passphrase.strip()
return passphrase
except IOError as (errno, strerror):
print 'Error reading passphrase file %s: %s' % (PASSPHRASEFILE,
strerror)
else:
if debug:
print 'passphrase file %s does not exist' % (PASSPHRASEFILE)
# Prompt user if PASSPHRASEFILE does not exist or could not be read.
from M2Crypto.util import passphrase_callback
return passphrase_callback(v, prompt1, prompt2)
#
# Call the rpc server.
......
Supports Markdown
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