> Is there some way to specify the passphrase for the private key that
> I've missed?
After a discussion with fumanchu, it seemed the best option was for me
to decrypt the server key myself if the user didn't want to
interactively enter the password, and then point cherrypy at the
decrypted key file. This snippet should be helpful to those wanting
to do the same thing (only works on *NIX-like platforms, only tested
on OpenSolaris):
def get_ssl_passphrase(*ignored):
p = retcode = None
try:
cmdline = "%s %s %d" % (ssl_dialog,
"''", port)
p = subprocess.Popen(cmdline,
shell=True,
stdout=subprocess.PIPE,
stderr=None)
retcode = p.wait()
except Exception, e:
print "pkg.depotd: an error occurred
while " \
"executing [%s]; unable to obtain
the " \
"passphrase needed to decrypt the
SSL" \
"private key file:
%s" (ssl_dialog, e)
sys.exit(1)
return p.stdout.read().strip("\n")
# The key file requires decryption, but the user has
requested
# exec-based authentication, so it will have to be
decoded first
# to an un-named temporary file.
try:
key_file = file(ssl_key_file, "rb")
pkey = crypto.load_privatekey
(crypto.FILETYPE_PEM,
key_file.read(), get_ssl_passphrase)
key_data = tempfile.TemporaryFile()
key_data.write(crypto.dump_privatekey(
crypto.FILETYPE_PEM, pkey))
key_data.seek(0)
except EnvironmentError, e:
print "pkg.depotd: unable to read the SSL
private " \
"key file: %s" % e
sys.exit(1)
except crypto.Error, e:
print "pkg.depotd: authentication or
cryptography " \
"failure while attempting to decode\nthe
SSL " \
"private key file: %s" % e
sys.exit(1)
else:
# Redirect the server to the decrypted key
file.
ssl_key_file = "/dev/fd/%d" % key_data.fileno
()
Thanks,
-Shawn