def _handle_cert(dbase, rec, links):
    """Internal function to handle a record corresponding to an X509
    certificate.

    """

    raw_data = dbase.from_binary(rec["value"])
    cert = Certificate.from_data(raw_data, hash_sha256=rec["infos"]["sha256"])
    rec["value"] = encode_b64(raw_data).decode()
    links.update(
        cert.link_to(
            CertificateSubject.get_or_create(value=rec["infos"]["subject_text"]),
            "cert-subject",
            "IVRE - X509 subject",
        )
    )
    links.update(
        cert.link_to(
            CertificateSubject.get_or_create(value=rec["infos"]["issuer_text"]),
            "cert-issuer",
            "IVRE - X509 issuer",
        )
    )
    commonname = rec["infos"]["subject"]["commonName"]
    if commonname:
        while commonname.startswith("*."):
            commonname = commonname[2:]
        if commonname:
            _try_link(
                links,
                cert,
                Hostname,
                commonname,
                "cert-commonname",
                "IVRE - X509 Subject commonName",
            )
    for san in rec["infos"].get("san", []):
        if san.startswith("DNS:"):
            san = san[4:]
            while san.startswith("*."):
                san = san[2:]
            if san:
                _try_link(
                    links, cert, Hostname, san, "cert-san", "IVRE - X509 subjectAltName"
                )
        elif san.startswith("IP Address:"):
            san = san[11:]
            if san:
                _try_link(
                    links, cert, Ip, san, "cert-san", "IVRE - X509 subjectAltName"
                )
        elif san.startswith("email:"):
            san = san[6:]
            if san:
                _try_link(
                    links, cert, Email, san, "cert-san", "IVRE - X509 subjectAltName"
                )
        elif san.startswith("URI:"):
            san = san[4:]
            if san:
                _try_link(
                    links, cert, Url, san, "cert-san", "IVRE - X509 subjectAltName"
                )
        else:
            LOG.debug("_handle_rec: cannot handle subjectAltName: %r", san)
    return cert
Internal function to handle a record corresponding to an X509
    certificate.

    
contrib/analytics/ivre_api/ivre_api.py