Skip to content
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

Implement support for implicit FTPS on port 990 #1122

Merged
merged 1 commit into from
Jun 26, 2024

Conversation

reidsunderland
Copy link
Member

Issue #1121. Adds another option to credentials, implicit_ftps.

It works with the ESA SMOS server I've been trying to connect to.

With just tls enabled (not implicit_ftps):

2024-06-25 15:58:20,515 [DEBUG] 466708 sarracenia.transfer.ftp connect Exception details:
Traceback (most recent call last):
  File "/net/local/home/sunderlandr/sr3/sarracenia/transfer/ftp.py", line 222, in connect
    ftp = ftplib.FTP_TLS(self.host,
  File "/usr/lib/python3.10/ftplib.py", line 740, in __init__
    super().__init__(host, user, passwd, acct,
  File "/usr/lib/python3.10/ftplib.py", line 123, in __init__
    self.login(user, passwd, acct)
  File "/usr/lib/python3.10/ftplib.py", line 745, in login
    self.auth()
  File "/usr/lib/python3.10/ftplib.py", line 753, in auth
    resp = self.voidcmd('AUTH TLS')
  File "/usr/lib/python3.10/ftplib.py", line 286, in voidcmd
    return self.voidresp()
  File "/usr/lib/python3.10/ftplib.py", line 259, in voidresp
    resp = self.getresp()
  File "/usr/lib/python3.10/ftplib.py", line 254, in getresp
    raise error_perm(resp)
ftplib.error_perm: 530 Please login with USER and PASS.

Note: this error is only because this particular server allows connections on port 21, but does not allow us to login. This fix should also work on servers that don't allow connections on port 21 at all.

With implicit_tls enabled, it uses the new code and works:

2024-06-25 16:04:21,326 [DEBUG] 468379 sarracenia.transfer.ftp connect sr_ftp connect ftp://[email protected]@smos-diss.eo.esa.int/
2024-06-25 16:04:21,326 [DEBUG] 468379 sarracenia.transfer.ftp credentials sr_ftp credentials ftp://[email protected]@smos-diss.eo.esa.int/
2024-06-25 16:04:25,934 [DEBUG] 468379 sarracenia.transfer.ftp cd sr_ftp cd /SMOS/L1CS/MIR_SCSF1C/2024/06
2024-06-25 16:04:26,145 [DEBUG] 468379 sarracenia.transfer.ftp ls sr_ftp ls
2024-06-25 16:04:26,663 [DEBUG] 468379 sarracenia.transfer.ftp ls sr_ftp ls = (size: 25) {'01': 'dr-x------ 3 oads oads 0 Jun 2 05:45 01', '02': 'dr-x------ 3 oads oads 0 Jun 3 05:21 02', '03': 'dr-x------ 3 oads oads 0 Jun 4 06:03 03', '04': 'dr-x------ 3 oads oads 0 Jun 5 07:19 04', '05': 'dr-x------ 3 oads oads 0 Jun 6 06:29 05', '06': 'dr ...
2024-06-25 16:04:26,740 [DEBUG] 468379 sarracenia.transfer.ftp cd sr_ftp cd /SMOS/L1CS/MIR_SCSF1C/2024/06/01

Copy link

Test Results

244 tests   243 ✅  1m 2s ⏱️
  1 suites    1 💤
  1 files      0 ❌

Results for commit 9cde524.

Copy link
Contributor

@petersilva petersilva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sigh... active/passive, tls/tcp, and now explicit/vs. implicit... ftp is such a nightmare.
I guess this is fine if it fixes the problem. Question... if you have the time... would it be reasonable to try/except this? I mean try one option, and if the connect fails then try the implicit one, then remember which one worked? I say this so that the analyst doesn't need to specify yet another FTP option... but this is fine as-is.

@reidsunderland
Copy link
Member Author

Yeah :(

I think a try/except to guess which one to use would be good. It might be tricky on cases like the ESA SMOS server I was trying where port 21 responds but doesn't allow login, but would still help in some cases. I'll merge this as is and try working on that separately.

@reidsunderland reidsunderland merged commit 6b49df1 into development Jun 26, 2024
30 of 37 checks passed
@reidsunderland reidsunderland deleted the issue1121_ftp_990 branch June 26, 2024 13:06
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

Successfully merging this pull request may close these issues.

None yet

2 participants