Skip to content

Issue with ftplib.FTP_TLS and server forcing SSL connection reuse #69623

Closed

Description

@dwaites
mannequin
BPO 25437
Nosy @tiran
Superseder
  • bpo-19500: ftplib: Add client-side SSL session resumption
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2016-09-08.23:09:48.027>
    created_at = <Date 2015-10-18.19:44:18.180>
    labels = ['type-bug', 'library']
    title = 'Issue with ftplib.FTP_TLS and server forcing SSL connection reuse'
    updated_at = <Date 2016-09-08.23:09:48.025>
    user = 'https://bugs.python.org/dwaites'

    bugs.python.org fields:

    activity = <Date 2016-09-08.23:09:48.025>
    actor = 'christian.heimes'
    assignee = 'none'
    closed = True
    closed_date = <Date 2016-09-08.23:09:48.027>
    closer = 'christian.heimes'
    components = ['Library (Lib)']
    creation = <Date 2015-10-18.19:44:18.180>
    creator = 'dwaites'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 25437
    keywords = []
    message_count = 3.0
    messages = ['253161', '253162', '275208']
    nosy_count = 3.0
    nosy_names = ['christian.heimes', 'dwaites', 'Stephen Ash']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = None
    status = 'closed'
    superseder = '19500'
    type = 'behavior'
    url = 'https://bugs.python.org/issue25437'
    versions = ['Python 2.7', 'Python 3.4']

    Activity

    1. dwaites commented on Oct 18, 2015

      dwaitesmannequin
      MannequinAuthor

      There is an issue with the python FTPS module in the standard library which appears to be related to SSL session reuse. I noticed when I updated to a recent version of Pure-FTPd (1.0.42), python's FTPS library client stopped working and generated an error in the ssl unwrap call when a data connection is opened after prot_p() is used. Checking the change log on that version of Pure-FTPd, there is this note:

      • The ONLY_ACCEPT_REUSED_SSL_SESSIONS switch (introduced in Pure-FTPd
        1.0.22 circa 2009, but disabled back then due to client compatibility
        concerns) is now on by default, except in broken clients compatibility mode.

      Turning on the broken clients compatibility mode in pure-ftpd makes the Python client work again, so I'm surmising this is related to pure-ftpd forcing SSL session reuse. My question is, is this something the Python standard library should detect, or is it a problem lower in the stack (i.e., libssl?) Incidentally, I can reproduce this behavior on Python 2.7 as well.

      Steps to reproduce:

      import ftplib
      ftp = ftplib.FTP_TLS(ftphost, ftpuser, ftppass)
      ftp.prot_p()
      ftp.retrbinary('RETR ' + cmofile, infile.write)
      Traceback (most recent call last): 
      File "/home/dwaites/bin/mysqlload.py", line 212, in 
      main() 
      File "/home/dwaites/bin/mysqlload.py", line 155, in main 
      site.retrbinary('RETR ' + cmofile, infile.write) 
      File "/usr/lib/python3.4/ftplib.py", line 449, in retrbinary 
      conn.unwrap() 
      File "/usr/lib/python3.4/ssl.py", line 788, in unwrap 
      s = self._sslobj.shutdown() 
      OSError: [Errno 0] Error
    2. added
      stdlibStandard Library Python modules in the Lib/ directory
      type-bugAn unexpected behavior, bug, or error
      on Oct 18, 2015
    3. dwaites commented on Oct 18, 2015

      dwaitesmannequin
      MannequinAuthor

      Incidentally, there appears to be an old bug report with a similar error message, although the error is encountered in a different context. http://bugs.python.org/issue10808 . Evidently, errors encountered in libssl aren't necessarily being propagated up to python.

    4. tiran commented on Sep 8, 2016

      @tiran
      Member

      I'm going to add session support in bpo-19500 (3.6).

    5. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions