def decompose_cert(cert): cert_name, cert_body = head_body(cert) common_name = cert_body['common_name'] tardata_body = body(cert_body['tardata']) crt_filename = keys_ending(tardata_body, 'crt')[0] csr_filename = keys_ending(tardata_body, 'csr')[0] key_filename = keys_ending(tardata_body, 'key')[0] crt = tardata_body[crt_filename] csr = tardata_body[csr_filename] key = tardata_body[key_filename] return cert_name, common_name, crt, csr, key
def transform_cert(self, cert): cert_name, cert_body = head_body(cert) if self.verbosity == 0: return {cert_name: cert_body.get('expiry', None)} elif self.verbosity == 1: tardata = head(cert_body['tardata']) cert_body['tardata'] = tardata return {cert_name: cert_body} elif self.verbosity == 2: cert = visit(cert, func=simple) elif self.verbosity == 3: cert = visit(cert, func=abbrev) return cert
def from_obj(obj): try: bundle_name, bundle_body = head_body(obj) common_name = bundle_body['common_name'] modhash = bundle_body['modhash'] expiry = bundle_body['expiry'] authority = bundle_body['authority'] bug = bundle_body.get('bug', None) sans = bundle_body.get('sans', None) destinations = bundle_body.get('destinations', None) timestamp = bundle_body['timestamp'] key, csr, crt = [None] * 3 tardata = bundle_body.pop('tardata', None) if tardata: files = tardata[bundle_name + '.tar.gz'] key = files[bundle_name + '.key'] csr = files[bundle_name + '.csr'] crt = files[bundle_name + '.crt'] except Exception as ex: import traceback traceback.print_exc() raise BundleFromObjError(ex) return common_name, modhash, key, csr, crt, bug, sans, expiry, authority, destinations, timestamp
def _decompose(cert, tardata=False): try: cert_name, cert_body = head_body(cert) common_name = cert_body['common_name'] timestamp = cert_body['timestamp'] modhash = cert_body['modhash'] expiry = cert_body['expiry'] authority = cert_body['authority'] bug = cert_body.get('bug', None) sans = cert_body.get('sans', None) destinations = cert_body.get('destinations', None) if tardata: files = cert_body['tardata'][fmt('{cert_name}.tar.gz')] key = files[fmt('{cert_name}.key')] csr = files[fmt('{cert_name}.csr')] crt = files[fmt('{cert_name}.crt')] else: key, csr, crt = [None] * 3 except KeyError as ke: print(ke) pprint(cert) raise CertFromJsonError(ke) return common_name, timestamp, modhash, key, csr, crt, bug, sans, expiry, authority, destinations
def expiry_sorting(cert): head, body = head_body(cert) return body.get('expiry', 0)
def timestamp_sorting(cert): head, body = head_body(cert) return body.get('timestamp', 0)
def default_sorting(cert): head, body = head_body(cert) return body.get('common_name', '')