title: EOF occurred in violation of protocol with Python ftplib
body: <p>I'm working on an implicit TLS connection program with Python ftplib. I tried the solution provided in question <a href="https://stackoverflow.com/questions/12164470/python-ftp-implicit-tls-connection-issue">python-ftp-implicit-tls-connection-issue</a>(including Rg Glpj's and Juan Moreno's answers) to make the connection. But when I call <code>retrline</code> or <code>retrbinary</code> after logging into the ftp server like this(<code>FTP_ITLS</code> is the subclass of <code>FTP_TLS</code>):</p>
  <pre><code>58 server = FTP_ITLS()
  59 server.connect(host=&quot;x.x.x.x&quot;, port=990)
  60 server.login(user=&quot;user&quot;, passwd=&quot;******&quot;)
  61 server.prot_p()
  62
  63 server.cwd(&quot;doc&quot;)
  64 print(server.retrlines('LIST'))
  65 # server.retrbinary('RETR contents.7z', open('contents.7z', 'wb').write)
  66 server.quit()
  </code></pre>
  <p>I got an EOF error:</p>
  <pre class="lang-none prettyprint-override"><code>Traceback (most recent call last):
    File &quot;D:/Coding/test/itls.py&quot;, line 64, in &lt;module&gt;
      print(server.retrlines('LIST'))
    File &quot;D:\Python\Python27\lib\ftplib.py&quot;, line 735, in retrlines
      conn = self.transfercmd(cmd)
    File &quot;D:\Python\Python27\lib\ftplib.py&quot;, line 376, in transfercmd
      return self.ntransfercmd(cmd, rest)[0]
    File &quot;D:\Python\Python27\lib\ftplib.py&quot;, line 713, in ntransfercmd
      server_hostname=self.host)
    File &quot;D:\Python\Python27\lib\ssl.py&quot;, line 352, in wrap_socket
      _context=self)
    File &quot;D:\Python\Python27\lib\ssl.py&quot;, line 579, in __init__
      self.do_handshake()
    File &quot;D:\Python\Python27\lib\ssl.py&quot;, line 808, in do_handshake
      self._sslobj.do_handshake()
  ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:590)
  </code></pre>
  <p>As it seems ftplib uses <code>PROTOCOL_SSLv23</code> as the default protocol in Python 2.7, I tried
  PROTOCOL_TLSv1, PROTOCOL_TLSv1_1 and PROTOCOL_TLSv1_2, but none of them worked. And I also tried overriding <code>ntransfercmd</code> and <code>auth</code>, or setting <code>ctx = ssl._create_stdlib_context(ssl.PROTOCOL_TLSv1)</code> as Steffen Ullrich said in question <a href="https://stackoverflow.com/questions/30276529/connect-to-ftp-tls-1-2-server-with-ftplib">connect-to-ftp-tls-1-2-server-with-ftplib</a>, but the error never disappeared. What can I do then? Thanks.</p>