import certs
import codes
import utils
+
+import logger
+
from config import read_config
from commonconfig import CMConfig
mycn = '%s-CA-KEY' % usename
self.ca_key_file = '%s/certmaster.key' % self.cfg.cadir
self.ca_cert_file = '%s/certmaster.crt' % self.cfg.cadir
+
+ self.logger = logger.Logger().logger
+ self.audit_logger = logger.AuditLogger().logger
+
try:
if not os.path.exists(self.cfg.cadir):
os.makedirs(self.cfg.cadir)
if method == 'trait_names' or method == '_getAttributeNames':
return self.handlers.keys()
+# ip = self.client_address
+# print ip
+
+# self.audit_logger.log_call(ip, method, params)
+
if method in self.handlers.keys():
return self.handlers[method](*params)
else:
+ self.logger.info("Unhandled method call for method: %s " % method)
raise codes.InvalidMethodException
def _sanitize_cn(self, commonname):
requesting_host = self._sanitize_cn(csrreq.get_subject().CN)
+
+ 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.certroot, requesting_host)
newsha.update(csrbuf)
newdig = newsha.hexdigest()
if not newdig == olddig:
+ self.logger.info("A cert for %s already exists and does not match the requesting cert" % (requesting_host))
# XXX raise a proper fault
return False, '', ''
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)
+ self.logger.info("cert for %s was autosigned" % (requesting_host))
return True, cert_buf, cacert_buf
else:
destfo.write(crypto.dump_certificate_request(crypto.FILETYPE_PEM, csrreq))
destfo.close()
del destfo
+ self.logger.info("cert for %s created and ready to be signed" % (requesting_host))
return False, '', ''
return False, '', ''
return
for fn in csrs + certs:
print 'Cleaning out %s for host matching %s' % (fn, hn)
+ self.logger.info('Cleaning out %s for host matching %s' % (fn, hn))
os.unlink(fn)
def sign_this_csr(self, csr):
try:
csrreq = crypto.load_certificate_request(crypto.FILETYPE_PEM, csr_buf)
except crypto.Error, e:
+ self.logger.info("Unable to sign %s: Bad CSR" % (csr))
raise exceptions.Exception("Bad CSR: %s" % csr)
else: # assume we got a bare csr req
server = CertmasterXMLRPCServer((xmlrpcinstance.cfg.listen_addr, CERTMASTER_LISTEN_PORT))
server.logRequests = 0 # don't print stuff to console
server.register_instance(xmlrpcinstance)
+ xmlrpcinstance.logger.info("certmaster started")
+ xmlrpcinstance.audit_logger.info("certmaster started")
server.serve_forever()
if self._no_handlers:
self._setup_handlers(logfilepath=logfilepath)
- def log_call(self, ip, CN, cert_hash, method, params):
+ def log_call(self, ip, method, params):
# square away a good parseable format at some point -akl
- self.logger.info("%s %s %s %s called with %s" % (ip, CN, cert_hash, method, params))
+ self.logger.info("%s called %s with %s" % (ip, method, params))
def _setup_logging(self):