title: Flower: Set SSL 'verify_mode'
body: <p><em>Using:</em> Flower 0.9.5 (installed Tornado 6.0.4), Celery 4.4.6, Python 3.7</p>
  <p>When starting <code>Flower</code> with</p>
  <pre><code>celery -A myProj flower
  </code></pre>
  <p>everything works as expected. Flower serves at <code>http://localhost:5555</code>.</p>
  <p>When starting <code>Flower</code> with</p>
  <pre><code>celery -A myProj flower --keyfile=/home/me/cert/key.pem --certfile=/home/me/cert/cert.pem
  </code></pre>
  <p>it serves at <code>https://localhost:5555</code> but when trying to access it, Chrome states <code>ERR_CONNECTION_RESET</code> and <code>Flower</code> logs</p>
  <pre><code>2020-09-16 17:19:37,421 - tornado.general - ERROR - Uncaught exception, closing connection.
  Traceback (most recent call last):
    File &quot;/home/me/.env/lib/python3.7/site-packages/tornado/iostream.py&quot;, line 711, in _handle_events
        self._handle_read()
    File &quot;/home/me/.env/lib/python3.7/site-packages/tornado/iostream.py&quot;, line 1498, in _handle_read
        self._do_ssl_handshake()
    File &quot;/home/me/.env/lib/python3.7/site-packages/tornado/iostream.py&quot;, line 1458, in _do_ssl_handshake
          if not self._verify_cert(self.socket.getpeercert()):
    File &quot;/home/me/.env/lib/python3.7/site-packages/tornado/iostream.py&quot;, line 1481, in _verify_cert
        assert verify_mode in (ssl.CERT_NONE, ssl.CERT_REQUIRED, ssl.CERT_OPTIONAL)
  UnboundLocalError: local variable 'verify_mode' referenced before assignment
  2020-09-16 17:19:37,423 - asyncio - ERROR - Exception in callback None()
  handle: &lt;Handle cancelled&gt;
  Traceback (most recent call last):
      File &quot;/home/me/python/lib/python3.7/asyncio/events.py&quot;, line 88, in _run
          self._context.run(self._callback, *self._args)
      File &quot;/home/me/.env/lib/python3.7/site-packages/tornado/platform/asyncio.py&quot;, line 139, in _handle_events
          handler_func(fileobj, events)
      File &quot;/home/me/.env/lib/python3.7/site-packages/tornado/iostream.py&quot;, line 711, in _handle_events
          self._handle_read()
      File &quot;/home/me/.env/lib/python3.7/site-packages/tornado/iostream.py&quot;, line 1498, in _handle_read
          self._do_ssl_handshake()
      File &quot;/home/me/.env/lib/python3.7/site-packages/tornado/iostream.py&quot;, line 1458, in _do_ssl_handshake
          if not self._verify_cert(self.socket.getpeercert()):
      File &quot;/home/me/.env/lib/python/site-packages/tornado/iostream.py&quot;, line 1481, in _verify_cert
          assert verify_mode in (ssl.CERT_NONE, ssl.CERT_REQUIRED, ssl.CERT_OPTIONAL)
  UnboundLocalError: local variable 'verify_mode' referenced before assignment
  </code></pre>
  <p><strong>Note:</strong> Everything works when running Flower with</p>
  <pre><code>celery -B brokerURL flower --keyfile=/home/me/cert/key.pem --certfile=/home/me/cert/cert.pem
  </code></pre>
  <p>In <code>/home/me/.env/lib/python3.7/site-packages/tornado/iostream.py</code> there is:</p>
  <pre><code>def _verify_cert(self, peercert: Any) -&gt; bool:
      &quot;&quot;&quot;Returns ``True`` if peercert is valid according to the configured
      validation mode and hostname.
  
      The ssl handshake already tested the certificate for a valid
      CA signature; the only thing that remains is to check
      the hostname.
      &quot;&quot;&quot;   
      if isinstance(self._ssl_options, dict):
          verify_mode = self._ssl_options.get(&quot;cert_reqs&quot;, ssl.CERT_NONE)
      elif isinstance(self._ssl_options, ssl.SSLContext):
          verify_mode = self._ssl_options.verify_mode
      assert verify_mode in (ssl.CERT_NONE, ssl.CERT_REQUIRED, ssl.CERT_OPTIONAL) # LINE 1481
      if verify_mode == ssl.CERT_NONE or self._server_hostname is None:
          return True
      cert = self.socket.getpeercert()
      if cert is None and verify_mode == ssl.CERT_REQUIRED:
          gen_log.warning(&quot;No SSL certificate given&quot;)
          return False
      try:
          ssl.match_hostname(peercert, self._server_hostname)
      except ssl.CertificateError as e:
          gen_log.warning(&quot;Invalid SSL certificate: %s&quot; % e)
          return False
      else:
          return True
  </code></pre>
  <p>How can I pass <code>verify_mode = ssl.CERT_REQUIRED</code> to <code>tornado</code> via <code>Flower</code>? Setting it manually inside <code>_verify_cert</code> does work.</p>