def perform_setup(self): # first, set up CA and host cert/key ca_name = self["ca.name"] if not os.path.exists(self.cadir): ca_name = self.ask_ca_name() self['ca.name'] = ca_name autoca.createCA(ca_name, self.basedir, self.cadir, log) if not ca_name: raise InvalidConfig("CA name is unknown") ca_cert = os.path.join(self.cadir, 'ca-certs/%s.pem' % ca_name) ca_key = os.path.join(self.cadir, 'ca-certs/private-key-%s.pem' % ca_name) pathutil.ensure_file_exists(ca_cert, "CA certificate") pathutil.ensure_file_exists(ca_key, "CA private key") hostname = self.get_hostname_or_ask() #TODO the hostcert/key creation should be extracted from here # right now it just does a bunch of redundant checks first checkssl.run(self.basedir, self.hostcert_path, self.hostkey_path, log, cadir=self.cadir, hostname=hostname) password = self['keystore.pass'] if not password: raise InvalidConfig("Keystore password is unknown") try: autoca.ensureKeystore(self.hostcert_path, self.hostkey_path, self.keystore_path, password, self.basedir, log) except autoca.KeystoreMismatchError: raise IncompatibleEnvironment( KEYSTORE_MISMATCH_MSG % { 'keystore': self.keystore_path, 'hostcert': self.hostcert_path, 'hostkey': self.hostkey_path }) pathutil.make_path_rw_private(self.keystore_path) # then setup GT container gtcontainer.adjust_hostname(hostname, self.basedir, self.gtdir, log) gtcontainer.adjust_secdesc_path(self.basedir, self.gtdir, log) gtcontainer.adjust_host_cert(self.hostcert_path, self.hostkey_path, self.basedir, self.gtdir, log) gtcontainer.adjust_gridmap_file(self.gridmap_path, self.basedir, self.gtdir, log) # and context broker gtcontainer.adjust_broker_config(ca_cert, ca_key, self.keystore_path, password, self.basedir, self.gtdir, log) # write an enviroment file self.write_env_file()
def perform_setup(self): # first, set up CA and host cert/key ca_name = self["ca.name"] if not os.path.exists(self.cadir): ca_name = self.ask_ca_name() self['ca.name'] = ca_name autoca.createCA(ca_name, self.basedir, self.cadir, log) if not ca_name: raise InvalidConfig("CA name is unknown") ca_cert = os.path.join(self.cadir, 'ca-certs/%s.pem' % ca_name) ca_key = os.path.join(self.cadir, 'ca-certs/private-key-%s.pem' % ca_name) pathutil.ensure_file_exists(ca_cert, "CA certificate") pathutil.ensure_file_exists(ca_key, "CA private key") hostname = self.get_hostname_or_ask() #TODO the hostcert/key creation should be extracted from here # right now it just does a bunch of redundant checks first checkssl.run(self.basedir, self.hostcert_path, self.hostkey_path, log, cadir=self.cadir, hostname=hostname) password = self['keystore.pass'] if not password: raise InvalidConfig("Keystore password is unknown") try: autoca.ensureKeystore(self.hostcert_path, self.hostkey_path, self.keystore_path, password, self.basedir, log) except autoca.KeystoreMismatchError: raise IncompatibleEnvironment(KEYSTORE_MISMATCH_MSG % { 'keystore' : self.keystore_path, 'hostcert' : self.hostcert_path, 'hostkey' : self.hostkey_path }) pathutil.make_path_rw_private(self.keystore_path) # then setup GT container gtcontainer.adjust_hostname(hostname, self.basedir, self.gtdir, log) gtcontainer.adjust_secdesc_path(self.basedir, self.gtdir, log) gtcontainer.adjust_host_cert(self.hostcert_path, self.hostkey_path, self.basedir, self.gtdir, log) gtcontainer.adjust_gridmap_file(self.gridmap_path, self.basedir, self.gtdir, log) # and context broker gtcontainer.adjust_broker_config(ca_cert, ca_key, self.keystore_path, password, self.basedir, self.gtdir, log) # write an enviroment file self.write_env_file()
def run(basedir, cadir, certconf, keyconf, hostnameconf, log): log.debug("Forcing a CA/hostcert install") # Reject relative paths if not pathutil.is_absolute_path(cadir): raise IncompatibleEnvironment("CA directory path is not absolute") if not pathutil.is_absolute_path(certconf): raise IncompatibleEnvironment("certificate path is not absolute") if not pathutil.is_absolute_path(keyconf): raise IncompatibleEnvironment("key path is not absolute") # The CA dir must not exist, create that first. autoca.createCA(pathutil.uuidgen(), basedir, cadir, log) print "Created auto CA: %s" % cadir # The configured certificate and key must not exist; create them. autoca.createCert(hostnameconf, basedir, cadir, certconf, keyconf, log) print "\nCreated hostcert: %s" % certconf print "Created hostkey: %s\n" % keyconf
def run(basedir, certconf, keyconf, log, cadir=None, hostname=None): log.debug("Checking SSL") # If the configurations themselves are missing, we cannot continue. if not certconf: raise IncompatibleEnvironment("There is no 'ssl.cert' configuration") if not keyconf: raise IncompatibleEnvironment("There is no 'ssl.key' configuration") # If the configurations are relative, they are assumed to be relative from # the base directory. if not pathutil.is_absolute_path(certconf): certconf = pathutil.pathjoin(basedir, certconf) log.debug("ssl.cert was a relative path, converted to '%s'" % certconf) if not pathutil.is_absolute_path(keyconf): keyconf = pathutil.pathjoin(basedir, keyconf) log.debug("ssl.key was a relative path, converted to '%s'" % keyconf) # If the configured certificate exists, check the key permissions, then # exit. missingcert = None missingkey = None if not pathutil.check_path_exists(certconf): missingcert = "Configured 'ssl.cert' does not exist at '%s'" % certconf if not pathutil.check_path_exists(keyconf): missingkey = "Configured 'ssl.key' does not exist at '%s'" % keyconf if not missingcert and not missingkey: log.debug("cert and key confs exist already, checking key perms") # check key permission if pathutil.is_path_private(keyconf): log.debug("key is owner-read only: %s" % keyconf) else: print >>sys.stderr, "***" print >>sys.stderr, "*** WARNING ***" print >>sys.stderr, "***" print >>sys.stderr, "SSL key has bad permissions, should only be readable by the file owner. ssl.key: '%s'" % keyconf return # If only one of the cert/key files exists, we cannot reason about # what to do: error. prefix = "Only one of the SSL cert/key file exists, cannot continue. " if missingcert and not missingkey: raise IncompatibleEnvironment(prefix + missingcert) if missingkey and not missingcert: raise IncompatibleEnvironment(prefix + missingkey) # The configured certificate and key do not exist; create them. print "Cannot find configured certificate and key for HTTPS, creating these for you." # If the internal CA does not exist, create that first. if not cadir: cadir = pathutil.pathjoin(basedir, "var/ca") if not pathutil.check_path_exists(cadir): print "\nCannot find internal CA, creating this for you.\n" print "Please pick a unique, one word CA name or hit return to use a UUID.\n" print "For example, if you are installing this on the \"Jupiter\" cluster, you could perhaps use \"JupiterNimbusCA\" as the name.\n" ca_name = raw_input("Enter a name: ") if not ca_name: ca_name = pathutil.uuidgen() print "You did not enter a name, using '%s'" % ca_name else: ca_name = ca_name.split()[0] print "Using '%s'" % ca_name autoca.createCA(ca_name, basedir, cadir, log) print "\nCreated internal CA: %s" % cadir if not hostname: print "\nEnter the fully qualified hostname of this machine. If you don't know or care right now, hit return to use 'localhost'.\n" hostname = raw_input("Hostname: ") if not hostname: hostname = "localhost" print "Using '%s'" % hostname autoca.createCert(hostname, basedir, cadir, certconf, keyconf, log) print "\nCreated certificate: %s" % certconf print "Created key: %s\n" % keyconf
def run(basedir, certconf, keyconf, log, cadir=None, hostname=None): log.debug("Checking SSL") # If the configurations themselves are missing, we cannot continue. if not certconf: raise IncompatibleEnvironment("There is no 'ssl.cert' configuration") if not keyconf: raise IncompatibleEnvironment("There is no 'ssl.key' configuration") # If the configurations are relative, they are assumed to be relative from # the base directory. if not pathutil.is_absolute_path(certconf): certconf = pathutil.pathjoin(basedir, certconf) log.debug("ssl.cert was a relative path, converted to '%s'" % certconf) if not pathutil.is_absolute_path(keyconf): keyconf = pathutil.pathjoin(basedir, keyconf) log.debug("ssl.key was a relative path, converted to '%s'" % keyconf) # If the configured certificate exists, check the key permissions, then # exit. missingcert = None missingkey = None if not pathutil.check_path_exists(certconf): missingcert = "Configured 'ssl.cert' does not exist at '%s'" % certconf if not pathutil.check_path_exists(keyconf): missingkey = "Configured 'ssl.key' does not exist at '%s'" % keyconf if not missingcert and not missingkey: log.debug("cert and key confs exist already, checking key perms") # check key permission if pathutil.is_path_private(keyconf): log.debug("key is owner-read only: %s" % keyconf) else: print >> sys.stderr, "***" print >> sys.stderr, "*** WARNING ***" print >> sys.stderr, "***" print >> sys.stderr, "SSL key has bad permissions, should only be readable by the file owner. ssl.key: '%s'" % keyconf return # If only one of the cert/key files exists, we cannot reason about # what to do: error. prefix = "Only one of the SSL cert/key file exists, cannot continue. " if missingcert and not missingkey: raise IncompatibleEnvironment(prefix + missingcert) if missingkey and not missingcert: raise IncompatibleEnvironment(prefix + missingkey) # The configured certificate and key do not exist; create them. print "Cannot find configured certificate and key for HTTPS, creating these for you." # If the internal CA does not exist, create that first. if not cadir: cadir = pathutil.pathjoin(basedir, "var/ca") if not pathutil.check_path_exists(cadir): print "\nCannot find internal CA, creating this for you.\n" print "Please pick a unique, one word CA name or hit return to use a UUID.\n" print "For example, if you are installing this on the \"Jupiter\" cluster, you could perhaps use \"JupiterNimbusCA\" as the name.\n" ca_name = raw_input("Enter a name: ") if not ca_name: ca_name = pathutil.uuidgen() print "You did not enter a name, using '%s'" % ca_name else: ca_name = ca_name.split()[0] print "Using '%s'" % ca_name autoca.createCA(ca_name, basedir, cadir, log) print "\nCreated internal CA: %s" % cadir if not hostname: print "\nEnter the fully qualified hostname of this machine. If you don't know or care right now, hit return to use 'localhost'.\n" hostname = raw_input("Hostname: ") if not hostname: hostname = "localhost" print "Using '%s'" % hostname autoca.createCert(hostname, basedir, cadir, certconf, keyconf, log) print "\nCreated certificate: %s" % certconf print "Created key: %s\n" % keyconf