def expired(certificate):
 ret = {}
 if os.path.isfile(certificate):
  try:
   ret['path'] = certificate
   cert = _get_certificate_obj(certificate)
   _now = datetime.datetime.utcnow()
   _expiration_date = cert.get_not_after().get_datetime()
   ret['cn'] = _parse_subject(cert.get_subject())['CN']
   if (_expiration_date.strftime('%Y-%m-%d %H:%M:%S') <= _now.strftime('%Y-%m-%d %H:%M:%S')):
    ret['expired'] = True
   else:
    ret['expired'] = False
  except ValueError:
   pass
 return ret

def expired ( certificate ) : ret = { } if os . path . isfile ( certificate ) : try : ret [ 'path' ] = certificate cert = _get_certificate_obj ( certificate ) _now = datetime . datetime . utcnow ( ) _expiration_date = cert . get_not_after ( ) . get_datetime ( ) ret [ 'cn' ] = _parse_subject ( cert . get_subject ( ) ) [ 'CN' ] if ( _expiration_date . strftime ( '%Y-%m-%d %H:%M:%S' ) <= _now . strftime ( '%Y-%m-%d %H:%M:%S' ) ) : ret [ 'expired' ] = True else : ret [ 'expired' ] = False except ValueError : pass return ret
returns a dict containing limited details of a certificate and whether the certificate has expired .