All pastes #605208 Raw Edit

Something

public text v1 · immutable
·published 2007-07-06 00:54 UTC
rendered paste body
import os, sys, time

count = 0;
for file in os.listdir(sys.argv[1]):
  if file[-3:] != "crt":
    continue
  crt = open(os.path.join(sys.argv[1], file), "r")
  for line in crt.readlines():
    if line.find("Not After") != -1:
      line = line.strip()
      tokens = line.split(": ")
      expire = time.mktime(time.strptime(tokens[1], "%b %d %H:%M:%S %Y %Z"))
      now = time.time()
      nextweek = now + 7*24*60*60
      if (expire <= now):
        print "%s has expired" % file
        count = 1;
      elif (expire <= nextweek):
        print "%s is going to expire in %d days" % (file, int((expire-now)/(24*60*60)))
        count = 1;


#if (count == 0):
#  print "No certificates expired";