- self.cakey[s_caname] = certs.retrieve_key_from_file(s_ca_key_file)
- self.cacert[s_caname] = certs.retrieve_cert_from_file(s_ca_cert_file)
+ a_ca.cakey = certs.retrieve_key_from_file(s_ca_key_file)
+ a_ca.cacert = certs.retrieve_cert_from_file(s_ca_cert_file)
- for dirpath in [a_ca['cadir'], a_ca['certroot'], a_ca['csrroot'], a_ca['csrroot']]:
+ for dirpath in [a_ca.cadir, a_ca.certroot, a_ca.csrroot, a_ca.csrroot]:
- def wait_for_cert(self, csrbuf, ca='', with_triggers=True):
+ def wait_for_cert(self, csrbuf, ca_name, with_triggers=True):
self.logger.info("%s requested signing of cert %s" % (requesting_host,csrreq.get_subject().CN))
# get rid of dodgy characters in the filename we're about to make
self.logger.info("%s requested signing of cert %s" % (requesting_host,csrreq.get_subject().CN))
# get rid of dodgy characters in the filename we're about to make
- certfile = '%s/%s.cert' % (self.cfg.ca[ca]['certroot'], requesting_host)
- csrfile = '%s/%s.csr' % (self.cfg.ca[ca]['csrroot'], requesting_host)
+ certfile = '%s/%s.cert' % (certauth.certroot, requesting_host)
+ csrfile = '%s/%s.csr' % (certauth.csrroot, requesting_host)
# check for old csr on disk
# if we have it - compare the two - if they are not the same - raise a fault
# check for old csr on disk
# if we have it - compare the two - if they are not the same - raise a fault
if os.path.exists(certfile):
slavecert = certs.retrieve_cert_from_file(certfile)
cert_buf = crypto.dump_certificate(crypto.FILETYPE_PEM, slavecert)
if os.path.exists(certfile):
slavecert = certs.retrieve_cert_from_file(certfile)
cert_buf = crypto.dump_certificate(crypto.FILETYPE_PEM, slavecert)
if with_triggers:
self._run_triggers(requesting_host,'/var/lib/certmaster/triggers/request/post/*')
return True, cert_buf, cacert_buf
if with_triggers:
self._run_triggers(requesting_host,'/var/lib/certmaster/triggers/request/post/*')
return True, cert_buf, cacert_buf
# if we're autosign then sign it, write out the cert and return True, etc, etc
# else write out the csr
# if we're autosign then sign it, write out the cert and return True, etc, etc
# else write out the csr
cert = certs.retrieve_cert_from_file(cert_fn)
cert_buf = crypto.dump_certificate(crypto.FILETYPE_PEM, cert)
cert = certs.retrieve_cert_from_file(cert_fn)
cert_buf = crypto.dump_certificate(crypto.FILETYPE_PEM, cert)
- cacert_buf = crypto.dump_certificate(crypto.FILETYPE_PEM, self.cacert[ca])
- self.logger.info("cert for %s for ca %s was autosigned" % (requesting_host,ca))
+ cacert_buf = crypto.dump_certificate(crypto.FILETYPE_PEM, certauth.cacert)
+ self.logger.info("cert for %s for ca %s was autosigned" % (requesting_host,ca_name))
if with_triggers:
self._run_triggers(None,'/var/lib/certmaster/triggers/request/post/*')
return True, cert_buf, cacert_buf
if with_triggers:
self._run_triggers(None,'/var/lib/certmaster/triggers/request/post/*')
return True, cert_buf, cacert_buf
- def remove_this_cert(self, hn, with_triggers=True, ca=''):
+ def remove_this_cert(self, hn, certauth, with_triggers=True):
certs = glob.glob(certglob)
if not csrs and not certs:
# FIXME: should be an exception?
certs = glob.glob(certglob)
if not csrs and not certs:
# FIXME: should be an exception?
- def sign_this_csr(self, csr, with_triggers=True, ca=''):
+ def sign_this_csr(self, csr, certauth,with_triggers=True):
- elif os.path.exists('%s/%s' % (self.cfg.ca[ca]['csrroot'], csr)): # we have a partial path?
- csrfo = open('%s/%s' % (self.cfg.ca[ca]['csrroot'], csr))
+ elif os.path.exists('%s/%s' % (certauth.csrroot, csr)): # we have a partial path?
+ csrfo = open('%s/%s' % (certauth.csrroot, csr))
- thiscert = certs.create_slave_certificate(csrreq, self.cakey[ca], self.cacert[ca], self.cfg.ca[ca]['cadir'])
+ thiscert = certs.create_slave_certificate(csrreq, certauth.cakey, certauth.cacert, certauth.cadir)
destfo = open(certfile, 'w')
destfo.write(crypto.dump_certificate(crypto.FILETYPE_PEM, thiscert))
destfo = open(certfile, 'w')
destfo.write(crypto.dump_certificate(crypto.FILETYPE_PEM, thiscert))
- def get_signed_certs(self, hostglobs=None, ca=''):
- certglob = "%s/*.cert" % (self.cfg.ca[ca]['certroot'])
+ def get_signed_certs(self, certauth,hostglobs=None):
+ certglob = "%s/*.cert" % (certauth.certroot)
- def get_cert_hashes(self, hostglobs=None,ca=''):
- certglob = "%s/*.cert" % (self.cfg.ca[ca]['certroot'])
+ def get_cert_hashes(self, certauth, hostglobs=None):
+ certglob = "%s/*.cert" % (certauth.certroot)