def generate_cert(root_ca_cert_str, server_cert_str, server_host):
  EXTENSION_WHITELIST = set(['subjectAltName'])

  if openssl_import_error:
    raise openssl_import_error  # pylint: disable=raising-bad-type

  common_name = server_host
  reused_extensions = []
  if server_cert_str:
    original_cert = load_cert(server_cert_str)
    common_name = original_cert.get_subject().commonName
    for i in xrange(original_cert.get_extension_count()):
      original_cert_extension = original_cert.get_extension(i)
      if original_cert_extension.get_short_name() in EXTENSION_WHITELIST:
        reused_extensions.append(original_cert_extension)

  ca_cert = load_cert(root_ca_cert_str)
  ca_key = load_privatekey(root_ca_cert_str)

  cert = crypto.X509()
  cert.get_subject().CN = common_name
  cert.gmtime_adj_notBefore(-60 * 60)
  cert.gmtime_adj_notAfter(60 * 60 * 24 * 30)
  cert.set_issuer(ca_cert.get_subject())
  cert.set_serial_number(int(time.time()*10000))
  cert.set_pubkey(ca_key)
  cert.add_extensions(reused_extensions)
  cert.sign(ca_key, 'sha256')

  return _dump_cert(cert)
Generates a cert_str with the sni field in server_cert_str signed by the
dataset/ETHPy150Open chromium/web-page-replay/certutils.py/generate_cert