Example ec2 client auto-installs certificates upon receiving cert

This commit is contained in:
James Kasten
2012-07-30 19:26:03 -04:00
parent 2c9629046a
commit 5a07d530f9
+6 -2
View File
@@ -123,7 +123,7 @@ print sni_todo
import sni_challenge import sni_challenge
import configurator import configurator
config = Configurator() config = configurator.Configurator()
config.get_virtual_hosts() config.get_virtual_hosts()
vhost = set() vhost = set()
for name in dn: for name in dn:
@@ -149,6 +149,7 @@ while r.challenge or r.proceed.IsInitialized():
# TODO: there should be a deploy_cert() here. # TODO: there should be a deploy_cert() here.
if r.success.IsInitialized(): if r.success.IsInitialized():
cert_chain_abspath = None
with open(cert_file, "w") as f: with open(cert_file, "w") as f:
f.write(r.success.certificate) f.write(r.success.certificate)
if r.success.chain: if r.success.chain:
@@ -157,8 +158,11 @@ if r.success.IsInitialized():
print "Server issued certificate; certificate written to " + cert_file print "Server issued certificate; certificate written to " + cert_file
if r.success.chain: if r.success.chain:
print "Cert chain written to " + chain_file print "Cert chain written to " + chain_file
# TODO: Uncomment the following assignment when the server
# presents a valid chain
#cert_chain_abspath = os.path.abspath(chain_file)
for host in vhost: for host in vhost:
config.deploy_cert(host, cert_file, chain_file, key_file) config.deploy_cert(host, os.path.abspath(cert_file), os.path.abspath(key_file), cert_chain_abspath)
elif r.failure.IsInitialized(): elif r.failure.IsInitialized():
print "Server reported failure." print "Server reported failure."
sys.exit(1) sys.exit(1)