示例#1
0
def get_pgpapi_keyinfo(keyid):
    # Load the key info.
    key = pgp.get_pgp_keyinfo(keyid)
    # Check if it's none before proceeding
    if not key:
        return "{}", 404, {"Content-Type": "application/json"}
    # Otherwise, return the key info
    return key.to_json(), 200, {"Content-Type": "application/json"}
示例#2
0
def getkeyinfo(key: str):
    if key.startswith("0x"):
        key = key.replace("0x", "")
    # Keyinfo route.
    keydata = pgp.get_pgp_keyinfo(key)
    if request.args.get("added", False): added = True
    else: added = False
    if keydata:
        keyascii = pgp.get_pgp_armor_key(key)
        return render_template("keyinfo.html", added=added, key=keydata, keydata=keyascii, found=True)
    else:
        return render_template("keyinfo.html", found=False, keyid=key), 404
示例#3
0
def add():
    # Get the key from the form
    key = request.form.get("enterkey")
    if not key:
        return render_template("submit.html")
    else:
        # Import the key
        imported = pgp.add_pgp_key(key)
        if not imported[0]:
            if imported[1] == -1:
                return render_template("submit.html", success=False, errormsg="Seems like an error happened importing your key. Double-check you copy/pasted it correctly.")
            elif imported[1] == -2:
                return render_template("submit.html", success=False, errormsg="Your key is already added on the server and is unchanged.")
            elif imported[1] == -3:
                return render_template("submit.html", success=False, errormsg="Your key was invalid and could not be imported.")
        else:
            keyinfo = pgp.get_pgp_keyinfo(imported[1])
            broadcast_add(imported[2])
            return redirect(url_for("frontend.getkeyinfo", key=keyinfo.shortid, added=True)), 302