code: def get_certificate_info():
      
      if hasattr(settings, 'MIT_WS_CERTIFICATE') and settings.MIT_WS_CERTIFICATE:
          mit_ws_certificate = settings.MIT_WS_CERTIFICATE
      else:
          return {"status": NO_CONFIG}
  
      app_cert = OpenSSL.crypto.load_certificate(
          OpenSSL.crypto.FILETYPE_PEM, (
              mit_ws_certificate if not isinstance(mit_ws_certificate, str)
              else mit_ws_certificate.encode().decode('unicode_escape').encode()
          )
      )
  
      app_cert_expiration = datetime.strptime(
          app_cert.get_notAfter().decode('ascii'),
          '%Y%m%d%H%M%SZ'
      )
      date_delta = app_cert_expiration - datetime.now()
  
      # if more then 30 days left in expiry of certificate then app is safe
      return {
          'app_cert_expires': app_cert_expiration.strftime('%Y-%m-%dT%H:%M:%S'),
          'status': UP if date_delta.days > 30 else DOWN
      }
docs: checks app certificate expiry status