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

Websocket error: SSL not available #1107

Closed
brentpicasso opened this issue Sep 2, 2017 · 6 comments
Closed

Websocket error: SSL not available #1107

brentpicasso opened this issue Sep 2, 2017 · 6 comments

Comments

@brentpicasso
Copy link
Contributor

Getting this error when attempting to open a secure websocket ('wss://') using websocket-client.

09-02 09:12:04.037 10328 10719 I python : [ERROR ] [MyApp] Websocket error: SSL not available.
09-02 09:12:04.037 10328 10719 I python : [INFO ] [MyApp] Websocket closed

Still happens after trying:

  • buildozer android clean
  • deleting the .buildozer directory and re-building
  • issuing buildozer android update and buildozer android clean and update

buildozer requirements:

requirements = kivy==1.10.0, sqlite3, openssl, pyopenssl, pygments, websocket-client

Other notes:

09-02 10:00:43.215 13478 13511 I python : [ERROR ] [MyApp] Websocket error: _ssl.c:331: No root certificates specified for verification of other-side certificates.

  • SSL does work on my android build; elsewhere in our app we are successfully using https with urllib2.
@brentpicasso
Copy link
Contributor Author

brentpicasso commented Sep 2, 2017

(strikethrough) update, I can run this example successfully

EDIT: I cannot get this example to run successfully in wss:// (secure) mode.
https://github.com/debauchery1st/example_kivy_websocket-recipe

Now digging into why mine works, first focusing on the buildozer spec differences. I see this example does not specify openssl or pyopenssl

@brentpicasso
Copy link
Contributor Author

To repro this problem, run the example here, and change the ws:// to wss:// to request secure mode.
https://github.com/debauchery1st/example_kivy_websocket-recipe

CC @debauchery1st - are you able to get SSL working with your websocket example?

@brentpicasso
Copy link
Contributor Author

Ok, a little bit more. digging into the _ssl_compact.py in websocket-clinet, it looks like my python is being built without backports.ssl_match_hostname:

Getting this exception when it's trying to import backports:

No module named backports.ssl_match_hostname

@brentpicasso
Copy link
Contributor Author

I think I figured it out.

Two things needed:

  • backports.ssl-match-hostname in buildozer requirements
  • needed ssl.CERT_NONE on cert_req parameter for the websocket run_forever: ws.run_forever(sslopt={"cert_reqs": ssl.CERT_NONE})

What's the next step? should py4a at least automatically include backports.ssl-match-hostname if SSL is included?

@tito
Copy link
Member

tito commented Sep 3, 2017

I'm not sure. I use ws4py and openssl module via requests. None of this is necessary. But thanks for the analysis

@brentpicasso
Copy link
Contributor Author

Thanks @tito - I guess improving docs is the best solution, hopefully it's discoverable for the next person that runs across it

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