def list_chain(name,tip=0): """ Will list the chain info in a html page About tip : if tip==0 name is a chain_name in the database if tip==1 the name is a list of X509 objects it was made to avoid writing the same method again...""" if tip==0:#it it will be retrieved from database dc=DbCert() res=dc.get_certids(name) #it will be retrieved from a cert list else: res=name #The res is a list of certification ids in the db if not res: return False final=[] final.append(certInfo['beginTag']%("Chain Information")) bindent="<blockquote>" eindent="</blockquote>" count=0 for c in res: final.append(3*bindent) linkname="".join(["cert",str(count)]) link="".join([linkname,".html"]) #print certInfo['chainInfo']%(link,linkname) final.append(certInfo['chainInfo']%(link,linkname)) count=count+1 #Store also the cert in another link: if tip==0: #pass it as an string ls=ListDb(buffer=dc.get_certData(c[0])) #print dc.get_certData(c[0]) else: #pass it as an object ls=ListDb(c,tip=1) ls.per_info(link) final.append(eindent*count*3) final.append(certInfo['endTag']) tofile=open("chain.html","w") tofile.write("".join(final)) tofile.close() os.system("/usr/bin/firefox chain.html") return True
def list_chain(name, tip=0): """ Will list the chain info in a html page About tip : if tip==0 name is a chain_name in the database if tip==1 the name is a list of X509 objects it was made to avoid writing the same method again...""" if tip == 0: #it it will be retrieved from database dc = DbCert() res = dc.get_certids(name) #it will be retrieved from a cert list else: res = name #The res is a list of certification ids in the db if not res: return False final = [] final.append(certInfo['beginTag'] % ("Chain Information")) bindent = "<blockquote>" eindent = "</blockquote>" count = 0 for c in res: final.append(3 * bindent) linkname = "".join(["cert", str(count)]) link = "".join([linkname, ".html"]) #print certInfo['chainInfo']%(link,linkname) final.append(certInfo['chainInfo'] % (link, linkname)) count = count + 1 #Store also the cert in another link: if tip == 0: #pass it as an string ls = ListDb(buffer=dc.get_certData(c[0])) #print dc.get_certData(c[0]) else: #pass it as an object ls = ListDb(c, tip=1) ls.per_info(link) final.append(eindent * count * 3) final.append(certInfo['endTag']) tofile = open("chain.html", "w") tofile.write("".join(final)) tofile.close() os.system("/usr/bin/firefox chain.html") return True
from digest.Hasher import DigestMan from initializer import DbCert from dbMain import LiteDb from sign.cert import X509Man dc = DbCert() sum = dc.selectS("select cert_sum from certs where ce_id=%s" % (7)) #print sum[0][0] #print dc.get_certData(2)[1:].split() d = DigestMan() sum2 = d.gen_buf_hash(dc.get_certData(7)[1:]) print sum2 if sum == sum2: print "The sum is ok" else: print "The cert was modified" sum3 = open("chain/cert2.pem", "r").read() sum3 = d.gen_buf_hash(sum3) #print sum3 #try to import it there c = X509Man() c.set_from_buf(dc.get_certData(7)[1:]) print c.get_detail()
from digest.Hasher import DigestMan from initializer import DbCert from dbMain import LiteDb from sign.cert import X509Man dc=DbCert() sum=dc.selectS("select cert_sum from certs where ce_id=%s"%(7)) #print sum[0][0] #print dc.get_certData(2)[1:].split() d=DigestMan() sum2=d.gen_buf_hash(dc.get_certData(7)[1:]) print sum2 if sum==sum2: print "The sum is ok" else: print "The cert was modified" sum3=open("chain/cert2.pem","r").read() sum3=d.gen_buf_hash(sum3) #print sum3 #try to import it there c=X509Man() c.set_from_buf(dc.get_certData(7)[1:]) print c.get_detail()