Пример #1
0
def deny(reqid):
    dbdata = util.load_db(jsonloader.conf.ra_options["certdb_file"])
    try:
        if dbdata[reqid].getStatus() == "Revoked":
            return "Cannot deny, certificate already Revoked"
        elif dbdata[reqid].getStatus() == "Issued":
            return "Cannot deny, certificate already Issued"
        elif dbdata[reqid].getStatus() == "Pending":
            dbdata[reqid].Denied = True
        elif dbdata[reqid].getStatus() == "Denied":
            return "Cannot deny, certificate already Denied"
        else:
            return "Cannot deny, Unkown state error"
        util.write_db(dbdata, jsonloader.conf.ra_options["certdb_file"])
        return dbdata[reqid].toInfoString()
    except Exception:
        return "Cannot find reqid %d in cert DB" % reqid
Пример #2
0
def fetch_cert(reqid):
    dbdata = util.load_db(jsonloader.conf.ra_options["certdb_file"])
    try:
        if dbdata[reqid].getStatus() == "Revoked":
            return "Cannot fetch, certificate is revoked"
        elif dbdata[reqid].getStatus() == "Issued":
            return dbdata[reqid].get_cert()
        elif dbdata[reqid].getStatus() == "Pending":
            return "Cannot fetch, certificate is not yet Issued"
        elif dbdata[reqid].getStatus() == "Denied":
            return "Cannot fetch, certificate request is Denied"
        else:
            return "Cannot fetch, Unkown state error"
        util.write_db(dbdata, jsonloader.conf.ra_options["certdb_file"])
        return dbdata[reqid].toInfoString()
    except Exception:
        return "Cannot find reqid %d in cert DB" % reqid
Пример #3
0
def revoke(reqid):
    dbdata = util.load_db(jsonloader.conf.ra_options["certdb_file"])
    try:
        if dbdata[reqid].getStatus() == "Revoked":
            return "Cannot revoke, certificate already Revoked"
        elif dbdata[reqid].getStatus() == "Issued":
            dbdata[reqid].Revoked = True
            dbdata[reqid].revocation_date = datetime.datetime.utcnow()
        elif dbdata[reqid].getStatus() == "Pending":
            return "Cannot revoke, certificate not Issued"
        elif dbdata[reqid].getStatus() == "Denied":
            return "Cannot revoke, certificate already Denied"
        else:
            return "Cannot revoke, Unkown state error"
        util.write_db(dbdata, jsonloader.conf.ra_options["certdb_file"])
        return dbdata[reqid].toInfoString()
    except Exception:
        return "Cannot find reqid %d in cert DB" % reqid
Пример #4
0
def issue(reqid):
    dbdata = util.load_db(jsonloader.conf.ra_options["certdb_file"])
    try:
        if dbdata[reqid].getStatus() == "Pending":
            dbdata[reqid].Issued = True
        elif dbdata[reqid].getStatus() == "Issued":
            return "Cannot issue, certificate already Issued"
        elif dbdata[reqid].getStatus() == "Denied":
            return "Cannot issue certificate already Denied"
        elif dbdata[reqid].getStatus() == "Revoked":
            return "Cannot issue certificate already Revoked"
    except Exception:
        return "Cannot find reqid %d in cert DB" % reqid

    dbdata[reqid].cert = certificate_ops.dispatch_sign(jsonloader.conf.ra_options["ra_name"],
                                                       dbdata[reqid].get_X509csr())[0].replace("\n", ""),
    util.write_db(dbdata, jsonloader.conf.ra_options["certdb_file"])
    return dbdata[reqid].toInfoString()