code: def isExpired(certificate):
      
      if isinstance(certificate, six.string_types):
          certificate = json.loads(certificate)
      expiry = certificate.get('expiry', 0)
      return expiry < int(time.time() * 1000) + 20 * 60
docs: Check if certificate is expired