def _extract_passive_SSL_cert(rec, cacert=False, server=True): script = {"id": "ssl-cacert" if cacert else "ssl-cert"} if server: port = { "state_state": "open", "state_reason": "passive", "port": rec["port"], "protocol": rec.get("protocol", "tcp"), "service_tunnel": "ssl", } else: port = { "port": -1, } info = rec["infos"] if info: pem = [] pem.append("-----BEGIN CERTIFICATE-----") pem.extend(wrap(utils.encode_b64(rec["value"]).decode(), 64)) pem.append("-----END CERTIFICATE-----") pem.append("") info["pem"] = "\n".join(pem) script["output"] = "\n".join(create_ssl_output(info)) script["ssl-cert"] = [info] port["scripts"] = [script] elif not server: # nothing interesting on a client w/o cert return {} return {"ports": [port]}
def _extract_passive_SSL_cert(rec, cacert=False, server=True): script = {"id": "ssl-cacert" if cacert else "ssl-cert"} if server: port = { 'state_state': 'open', 'state_reason': "passive", 'port': rec['port'], 'protocol': rec.get('protocol', 'tcp'), 'service_tunnel': 'ssl', } else: port = { 'port': -1, } info = rec['infos'] if info: pem = [] pem.append('-----BEGIN CERTIFICATE-----') pem.extend(wrap(utils.encode_b64(rec['value']).decode(), 64)) pem.append('-----END CERTIFICATE-----') pem.append('') info['pem'] = '\n'.join(pem) script['output'] = "\n".join(create_ssl_output(info)) script['ssl-cert'] = [info] port['scripts'] = [script] elif not server: # nothing interesting on a client w/o cert return {} return {'ports': [port]}