Changeset 1125
- Timestamp:
- 11/21/06 10:00:32 (7 years ago)
- Location:
- ccsd/trunk
- Files:
-
- 1 added
- 1 edited
-
crcnetd/_utils/ccsd_ca.py (modified) (4 diffs)
-
scripts/retrieve-ccsd-crl (added)
Legend:
- Unmodified
- Added
- Removed
-
ccsd/trunk/crcnetd/_utils/ccsd_ca.py
r1082 r1125 124 124 125 125 return (csr, key) 126 127 @exportViaXMLRPC(SESSION_RO, AUTH_AUTHENTICATED) 128 def fetchCRL(self): 129 130 ca = ccs_ca(ADMIN_SESSION_ID) 131 132 # Check when the next CRL is due 133 os.environ["CCS_CA_DIR"] = ca.rDir 134 (fdi, fdo) = os.popen2("openssl crl -text -in %s/crl.pem 2>&1" % ca.rDir) 135 fdi.close() 136 lines = fdo.readlines() 137 fdo.close() 138 del os.environ["CCS_CA_DIR"] 139 140 try: 141 for line in lines: 142 if line.strip().startswith("Next Update"): 143 parts = line.strip().split(":") 144 tmp = ":".join(parts[1:]).strip() 145 next = time.mktime(time.strptime(tmp, \ 146 "%b %d %H:%M:%S %Y %Z")) 147 now = time.time() 148 if (next - now) < (60*60*24*2): 149 # Update the CRL if it expires in less than 2 days 150 ca.updateCRL() 151 ca.checkin("Updated CRL to satisfy user request") 152 break 153 except: 154 log_error("Could not parse CRL output. " \ 155 "Returned CRL may be old.\n%s" % "".join(lines), \ 156 sys.exc_info()) 157 158 # Read and return the CRL 159 crl = open("%s/crl.pem" % ca.rDir, "r").read() 160 return crl 126 161 127 162 ##################################################################### … … 560 595 cert = open(certfile, "r").read() 561 596 return cert 562 597 598 def updateCRL(self): 599 """Regenerates the Certificate Revocation List""" 600 601 os.environ["CCS_CA_DIR"] = self.rDir 602 (fdi, fdo) = os.popen2("openssl ca -config %s/ca.cnf -gencrl -out " \ 603 "%s/crl.pem -batch 2>&1" % (self.rDir, self.rDir)) 604 fdi.close() 605 rlines = fdo.readlines() 606 fdo.close() 607 del os.environ["CCS_CA_DIR"] 608 609 return True 610 563 611 def revoke(self, serial, reasonCode=REVOKE_UNSPECIFIED, reasonText=""): 564 612 """Revokes the specified certificate optionally giving a reason … … 578 626 lines = fdo.readlines() 579 627 fdo.close() 580 (fdi, fdo) = os.popen2("openssl ca -config %s/ca.cnf -gencrl -out " \581 "%s/crl.pem -batch 2>&1" % (self.rDir, self.rDir))582 fdi.close()583 rlines = fdo.readlines()584 fdo.close()585 628 del os.environ["CCS_CA_DIR"] 586 629 … … 607 650 log_error("Could not move revoked certificate to new name!", \ 608 651 sys.exc_info()) 652 653 # Generate a new CRL 654 self.updateCRL() 609 655 610 656 # Commit the changes
Note: See TracChangeset
for help on using the changeset viewer.
