From ee1377800c043f9790f57faa91fdc04961ed9e80 Mon Sep 17 00:00:00 2001 From: Tony Mack Date: Tue, 10 Feb 2009 01:40:05 +0000 Subject: [PATCH] if server private key exists, create certificate using it. If neither key or cert exist, create both --- geni/plc.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/geni/plc.py b/geni/plc.py index a30225d5..6294b550 100644 --- a/geni/plc.py +++ b/geni/plc.py @@ -62,11 +62,19 @@ def main(): key_file = "server.key" cert_file = "server.cert" - # if no key is specified, then make one up - if (not os.path.exists(key_file)) or (not os.path.exists(cert_file)): + if (os.path.exists(key_file)) and (not os.path.exists(cert_file)): + # If private key exists and cert doesnt, recreate cert + key = Keypair(filename=key_file) + cert = Certificate(subject="registry") + cert.set_issuer(key=key, subject="registry") + cert.set_pubkey(key) + cert.sign() + cert.save_to_file(cert_file) + + elif (not os.path.exists(key_file)) or (not os.path.exists(cert_file)): + # if no key is specified, then make one up key = Keypair(create=True) key.save_to_file(key_file) - cert = Certificate(subject="registry") cert.set_issuer(key=key, subject="registry") cert.set_pubkey(key) -- 2.43.0