Skip to content

upgrade_to_tls does not work correctly #186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
astrand opened this issue Apr 14, 2025 · 2 comments
Open

upgrade_to_tls does not work correctly #186

astrand opened this issue Apr 14, 2025 · 2 comments

Comments

@astrand
Copy link

astrand commented Apr 14, 2025

Kind of follow up to #184. Explicit FTPS works now, however:

  • Not possible to use the context API, since there is no way to call updgrade_to_tls() in between client.connect() and client.login().
  • I was not able to download from pyftpdlib until I used this construction:
await client.upgrade_to_tls(self.ssl_context)
client._upgraded_to_tls = True # pylint: disable=protected-access
client._open_connection = functools.partial(asyncio.open_connection, ssl=client.ssl) # pylint: disable=protected-access

AFAIK, _upgraded_to_tls is never set in the actual code, and _open_connection is incorrect after update since it is not update with new ssl instance.

@pohmelie
Copy link
Collaborator

Thank you for the report. Will try to check this out in couple days.

@astrand
Copy link
Author

astrand commented Apr 15, 2025

Thanks. For testing, I am using this FTP server:

#!/usr/bin/env python3
"""FTPS server which requires explicit TLS"""
import os
import sys
from pyftpdlib.authorizers import DummyAuthorizer
from pyftpdlib.handlers import TLS_FTPHandler
from pyftpdlib.servers import FTPServer
def main():
    "Main"
    authorizer = DummyAuthorizer()
    authorizer.add_anonymous(".", perm="elradfmwMT")
    handler = TLS_FTPHandler
    handler.authorizer = authorizer
    handler.certfile = os.path.dirname(__file__) + "my.crt"
    handler.tls_control_required = True
    handler.tls_data_required = True
    server = FTPServer(("127.0.0.1", int(sys.argv[1])), handler)
    server.serve_forever()
if __name__ == "__main__":
    main()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants