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

ValueError: check_hostname requires server_hostname with Roomba password.py #122

Open
danielkhan opened this issue Dec 2, 2023 · 11 comments

Comments

@danielkhan
Copy link

After the device was found, I am asked to press the home button.
Once I press enter on the console, I get this error:

Traceback (most recent call last):
  File "./password.py", line 294, in <module>
    main()
  File "./password.py", line 291, in main
    get_passwd.get_password()
  File "./password.py", line 160, in get_password
    data = self.get_password_from_roomba(addr)
  File "./password.py", line 196, in get_password_from_roomba
    wrappedSocket = context.wrap_socket(sock)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ssl.py", line 997, in _create
    raise ValueError("check_hostname requires server_hostname")
ValueError: check_hostname requires server_hostname
@matteo-martinelli
Copy link

Same here!

@NickWaterton
Copy link
Owner

What Roomba do you have? For new Roomba’s you have to use a different process, as described in the instructions.

The method you are trying only works on older Roomba’s.

@NickWaterton
Copy link
Owner

Ok, I have looked into this. There are two possible fixes, maybe one of you can test this out.

in file password.py

  1. change PROTOCOL_TLS_ CLIENT on line 194 to PROTOCOL_TLS_SERVER
  2. change context.wrap_socket(sock) on line 196 to connect.wrap_socket(sock, server_hostname=addr)

If you could try 1) or 2) above (but not both), and let me know which (if any) works, I will update the code. I can’t test it myself, as I only have new Roombas.

@Idaho947
Copy link

Idaho947 commented Dec 22, 2023

I try and :

no change :
Traceback (most recent call last): File "/mnt/c/WINDOWS/system32/Roomba980-Python/roomba/password.py", line 294, in <module> main() File "/mnt/c/WINDOWS/system32/Roomba980-Python/roomba/password.py", line 291, in main get_passwd.get_password() File "/mnt/c/WINDOWS/system32/Roomba980-Python/roomba/password.py", line 160, in get_password data = self.get_password_from_roomba(addr) File "/mnt/c/WINDOWS/system32/Roomba980-Python/roomba/password.py", line 196, in get_password_from_roomba wrappedSocket = context.wrap_socket(sock) File "/usr/lib/python3.10/ssl.py", line 513, in wrap_socket return self.sslsocket_class._create( File "/usr/lib/python3.10/ssl.py", line 1028, in _create raise ValueError("check_hostname requires server_hostname") ValueError: check_hostname requires server_hostname

1 change not 2 :
2023-12-22 19:55:54 ERROR [Roomba.Password] Connection Error (for 192.168.1.81): Cannot create a client socket with a PROTOCOL_TLS_SERVER context (_ssl.c:811)

1 and 2 :

2023-12-22 19:57:29 INFO [Roomba.Password] Roomba (Jet M6) IP address is: 192.168.1.81
Traceback (most recent call last):
  File "/mnt/c/WINDOWS/system32/Roomba980-Python/roomba/password.py", line 294, in <module>
    main()
  File "/mnt/c/WINDOWS/system32/Roomba980-Python/roomba/password.py", line 291, in main
    get_passwd.get_password()
  File "/mnt/c/WINDOWS/system32/Roomba980-Python/roomba/password.py", line 160, in get_password
    data = self.get_password_from_roomba(addr)
  File "/mnt/c/WINDOWS/system32/Roomba980-Python/roomba/password.py", line 196, in get_password_from_roomba
    wrappedSocket = connect.wrap_socket(sock, server_hostname=addr)
NameError: name 'connect' is not defined. Did you mean: 'context'?

1 not change and 2 :

2023-12-22 20:00:03 ERROR [Roomba.Password] Connection Error (for 192.168.1.81): [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1007)
2023-12-22 20:00:03 ERROR [Roomba.Password] Unable to get password from roomba
2023-12-22 20:00:03 ERROR [Roomba.Password] Error getting password for robot Jet M6 at ip192.168.1.81, received 0 bytes. Follow the instructions and try again.

@paulwouters
Copy link

Ok, I have looked into this. There are two possible fixes, maybe one of you can test this out.

in file password.py

1. change `PROTOCOL_TLS_ CLIENT` on line 194 to `PROTOCOL_TLS_SERVER`

2. change `context.wrap_socket(sock)` on line 196 to `connect.wrap_socket(sock, server_hostname=addr)`

If you could try 1) or 2) above (but not both), and let me know which (if any) works, I will update the code. I can’t test it myself, as I only have new Roombas.

  1. works for me, but "connect" has to be "context", so:

context.wrap_socket(sock, server_hostname=addr)

@paulwouters
Copy link

note i still had an issue of the script exploding because I have two roombas and one was downstairs on its charger, so I couldn't press the home button :)

@Idaho947
Copy link

You have to the button and after press enter so you have time.

@Gurbmeister
Copy link

I came across the same problem. although i got it through the cloud option :)
nonetheless I checked these options. and both seemed to work.

@32nmud
Copy link

32nmud commented Jan 19, 2024

I'm getting the same issue and none of the above solutions are working for me.

Ok, I have looked into this. There are two possible fixes, maybe one of you can test this out.

in file password.py

  1. change PROTOCOL_TLS_ CLIENT on line 194 to PROTOCOL_TLS_SERVER
  2. change context.wrap_socket(sock) on line 196 to connect.wrap_socket(sock, server_hostname=addr)

If you could try 1) or 2) above (but not both), and let me know which (if any) works, I will update the code. I can’t test it myself, as I only have new Roombas.

For 1, I get the Cannot create a client socket with a PROTOCOL_TLS_SERVER context (_ssl.c:809) issue.
For 2, I get Connection Error (for <ip addr>): [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1006) when I change connect to context in the solution. With connect as the solution suggests I get a NameError as mentioned by @Idaho947.

I've got the S9+, and as a sanity check I also attempted all the same steps both with the vacuum linked and unlinked to my Google account.

I'd be happy to perform further troubleshooting steps as necessary

@NickWaterton
Copy link
Owner

@32nmud

The process you are attempting does not work on modern Roombas like the S9+.

For modern Roombas, you have to use the cloud connection method to get the password, as described in the documentation.

@iointerrupt
Copy link

iointerrupt commented Feb 6, 2024

Wondering if for non-cloud Roomba connections, it makes sense to bypass hostname and certificate validity checks altogether? Heres what I use since these are all local roombas and I trust them ;-).

context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
context.check_hostname = False
context.verify_mode = ssl.CERT_NONE

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

8 participants