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

FTP_TLS error "extra keyword arguments given" on Pico W (RP2) port #18

Closed
JMFUS opened this issue Dec 13, 2023 · 14 comments
Closed

FTP_TLS error "extra keyword arguments given" on Pico W (RP2) port #18

JMFUS opened this issue Dec 13, 2023 · 14 comments
Labels

Comments

@JMFUS
Copy link

JMFUS commented Dec 13, 2023

Hello
Here is my code :

import network
from ftplibtls import FTP_TLS

status_reseau = connect_wifi_local("NETWORK", "123456789")[1]

if status_reseau == 3:

    try:
        
        ftp_tls = FTP_TLS()
        print("1")
        ftp_tls.connect(adresse_serveur, port)
        print("2")
        ftp_tls.login(utilisateur_1, mot_de_passe_1)
        print("3")
        ftp_tls.prot_p()
        print("4")
        files = ftp_tls.nlst()
        print(files)
        
    except Exception as e:
        erreur = str(e)
        print("Erreur FTPS : " + str(e))

But I have the following error on the login line :

Erreur FTPS : extra keyword arguments given

Someone can help me?

Thx

@SpotlightKid
Copy link
Owner

Please remove the wrapping of the code in a try/except block and run it again. That way you will get a full exception traceback, which shows where the error happens exactly.

@JMFUS
Copy link
Author

JMFUS commented Dec 13, 2023

Thx for your answer
Now I have :
Traceback (most recent call last):
File "", line 142, in
File "ftplibtls.py", line 63, in login
File "ftplibtls.py", line 80, in auth
TypeError: extra keyword arguments given

@SpotlightKid
Copy link
Owner

Which Micropython port are you using? Unix, stm32, esp2866, esp32, etc. ?

@SpotlightKid SpotlightKid added the needs feedback waiting for feedback from reporter or third-party label Dec 13, 2023
@JMFUS
Copy link
Author

JMFUS commented Dec 13, 2023

I'm working on a Raspberry Pi Pico W with Micropython 1.20
My FTP server is a Filezilla 0.9.60 server with this options
image

@SpotlightKid
Copy link
Owner

The Pico W port is unfortunately not supported yet, since I don't have a Pico W board to test against.

The API of the socket and ssl modules is slightly different on each MicroPython port and it seems that the ssl.wrap_socket function on the Pico W port does not support all the keyword arguments used by the current ftplibtls code.

You can try whether the variant for the ESP boards in the esp/ftplib.py and esp/ftplibtls.py files works on the Pico W as well, but they may very well do not.

Alternatively, you can try changing lines 77-80 of ftplibtls.py to:

        wrapped = ssl.wrap_socket(sock,
                                  keyfile=self.keyfile,
                                  certfile=self.certfile)

i.e. remove the cert_reqs keyword argument.


P.S.: If someone would sponsor me by sending me a Pico W board, I could "officially" support the Pico W port 😀

@SpotlightKid SpotlightKid added bug help wanted and removed needs feedback waiting for feedback from reporter or third-party labels Dec 13, 2023
@JMFUS
Copy link
Author

JMFUS commented Dec 13, 2023

I changed the lines 77-80 of the ftplibtls.py but the result is the same :(

@SpotlightKid
Copy link
Owner

Try removing the keyfile and certfile arguments as well.

Note: of course this means that no certificate validation will take place, which partly defeats the purpose of using TLS. So use at your own risk!

@JMFUS
Copy link
Author

JMFUS commented Dec 13, 2023

I allready tried to remove all argumentsand it's working
I understand there's a risk

@SpotlightKid SpotlightKid changed the title FTP_TLS error FTP_TLS error "extra keyword arguments given" on Pico W (RP2) port Dec 13, 2023
@JMFUS
Copy link
Author

JMFUS commented Dec 13, 2023

I can connect to my FTPS server but I can't list the files of my directory
line = b'220-FileZilla Server 0.9.60 beta\r\n'
line = b'220-written by Tim Kosse (tim.kosse@filezilla-project.org)\r\n'
line = b'220 Please visit https://filezilla-project.org/\r\n'
line = b'234 Using authentication type TLS\r\n'
line = b'331 Password required for jeanmarcf\r\n'
line = b'230 Logged on\r\n'
line = b'200 PBSZ=0\r\n'
line = b'200 Protection level set to P\r\n'
line = b'200 Type set to A\r\n'
line = b'227 Entering Passive Mode (88,122,12,99,128,235)\r\n'
line = b'150 Opening data channel for directory listing of "/"\r\n'
resp : 150 Opening data channel for directory listing of "/"
sock =
Traceback (most recent call last):
File "", line 122, in
File "ftplib.py", line 509, in retrlines
File "ftplibtls.py", line 136, in ntransfercmd
OSError: stream operation not supported

@SpotlightKid
Copy link
Owner

SpotlightKid commented Dec 13, 2023

This seems to be another incompatibility of the socket or ssl module on the RP2.

I can only repeat: the RP2 is not supported and unless I can get my hands on a Pico W board, I can do nothing about it.

I suggest looking for help on the MicroPython forum until then:

https://forum.micropython.org/viewforum.php?f=21

@JMFUS
Copy link
Author

JMFUS commented Dec 13, 2023

Thx

@SpotlightKid
Copy link
Owner

I finally got my hands on a Raspberry Pi Pico W board and I believe this issue is now fixed and FTP over TLS also works on the rp2 port.

@JMFUS I would appreciate if you could test this and confirm that it works for you.

Please see the README for usage notes.

@SpotlightKid SpotlightKid added needs feedback waiting for feedback from reporter or third-party and removed help wanted labels Feb 8, 2024
@JMFUS
Copy link
Author

JMFUS commented Feb 8, 2024

Hi
Thx for the work
I'm actuelly devopping other thing but when it will finished, I'll test this version and comme back to you

@SpotlightKid
Copy link
Owner

Assuming this to be fixed by 6c19a84.

Feel free to re-open, if the error persists with the latest version of the code in this repo.

If you have any other problems using this on the PR2 (or any other) port, please open a new ticket.

@SpotlightKid SpotlightKid removed the needs feedback waiting for feedback from reporter or third-party label Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants