jsxc / xmpp-cloud-auth

:key: Authentication hub for Nextcloud+JSXC→Prosody, ejabberd, saslauthd, Postfix
https://www.jsxc.org
MIT License
60 stars 18 forks source link

Python error on testing external_cloud.py #17

Closed marxistvegan closed 7 years ago

marxistvegan commented 7 years ago

Hey folks, So I followed the instructions I thought to a 'T'

The nextcloud instance can talk the 'bosh' 'internal_plain' works to login

When I try to use this I am not able to login, on the client says not authorized, so I tried to run
./external_cloud.py -c /etc/external_cloud.conf -l /var/log/prosody/ -I <nextcloud user> <nextcloud domain>

2017-06-07 19:02:08,548 INFO: Start external auth script 0.2.0+ for prosody with endpoint: https://nextcloud.dev.glocal.coop/index.php/apps/ojsxc/ajax/externalApi.php
2017-06-07 19:02:08,572 INFO: Starting new HTTPS connection (1): nextcloud.dev.glocal.coop
Traceback (most recent call last):
  File "./external_cloud.py", line 262, in <module>
    success = is_user(ISUSER_TEST[0], ISUSER_TEST[1])
  File "./external_cloud.py", line 180, in is_user
    if is_user_cloud(username, server):
  File "./external_cloud.py", line 103, in is_user_cloud
    'domain':server
  File "./external_cloud.py", line 43, in send_request
    logging.warn('An error occured during the request: %s' % err)
TypeError: __str__ returned non-string (type Error)

Not sure where to start

MarcelWaldvogel commented 7 years ago

Googling for TypeError: __str__ returned non-string (type Error) gave a few links related to the requests library which external_cloud.py also uses, e.g. https://github.com/requests/requests/issues/2524. They seem to be related to handling SSL errors.

I checked your URL, and the certificate expired in February. I would expect fixing this to solve the problem.

I agree, however, that the error message is horrible, at best. I will try to find out why it doesn't show anything better.

MarcelWaldvogel commented 7 years ago

The weirdness of the error message seems to be version dependent.

On Ubuntu 16.04 (Python 2.7.12, requests 2.16.5), the message is: WARNING: An error occured during the request: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590); on Ubuntu 17.04 (Python 2.7.13, requests 2.10.0), WARNING: An error occured during the request: ("bad handshake: Error([('SSL routines', 'ssl3_get_server_certificate', 'certificate verify failed')],)",).

Maybe updating your requests library would create a more helpful error message?

MarcelWaldvogel commented 7 years ago

Here is an experimental fix (aka hack): Can you try fdf9d86259d76f3d71d897e8d71a5775c626cfb5?

marxistvegan commented 7 years ago

Thanks! Good catch! Now a different error that i think i can resolve but this is resolved from updating the cert :)

MarcelWaldvogel commented 7 years ago

"Fixed" by fdf9d86259d76f3d71d897e8d71a5775c626cfb5 (making the error message clearer for older request/urllib/ssl errors)