linkedin / pyexchange

Python wrapper for Microsoft Exchange
Apache License 2.0
153 stars 98 forks source link

line 67 in connection.py unhandled exception #38

Open jkottapa opened 9 years ago

jkottapa commented 9 years ago

The try-catch block has a unhandled exception in the catch statement in line 67. This happens when we pass a url that is of type 'https' but it does not have a valid certificate certified by a CA.

This throws the following exception: >>> c.list_events(start=start_xchange, end=end_exchange, details=True) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python2.7/dist-packages/pyexchange/exchange2010/__init__.py", line 95, in list_events return Exchange2010CalendarEventList(service=self.service, start=start, end=end, details=details) File "/usr/local/lib/python2.7/dist-packages/pyexchange/exchange2010/__init__.py", line 113, in __init__ response_xml = self.service.send(body) File "/usr/local/lib/python2.7/dist-packages/pyexchange/base/soap.py", line 34, in send response = self._send_soap_request(request_xml, headers=headers, retries=retries, timeout=timeout, encoding=encoding) File "/usr/local/lib/python2.7/dist-packages/pyexchange/exchange2010/__init__.py", line 44, in _send_soap_request return super(Exchange2010Service, self)._send_soap_request(body, headers=headers, retries=retries, timeout=timeout, encoding=encoding) File "/usr/local/lib/python2.7/dist-packages/pyexchange/base/soap.py", line 65, in _send_soap_request response = self.connection.send(body, headers, retries, timeout) File "/usr/local/lib/python2.7/dist-packages/pyexchange/connection.py", line 67, in send log.debug(err.response.content) AttributeError: 'NoneType' object has no attribute 'content'

This is thrown because of _ssl.c:504: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed in the requests (line 64) has verify=True set by default. Turning that flag off does everything normally.

catermelon commented 9 years ago

Sorry about that - let me take a look.

solderluke commented 9 years ago

verify=False in the requests.post in connection.py is a hack but works for me for now.

Better is the option for adding args to include using certs like adding to the requests.post args: "verify=ca_crt, cert=(cert_pem,key_pem)" or if desired "verify=False" I guess.

catermelon commented 9 years ago

Yeah, that's a great idea. I'm sorry I haven't had much time to work on this lately, but I should have time this week.

catermelon commented 9 years ago

(pull requests gladly received btw)

deronnax commented 9 years ago

https://github.com/linkedin/pyexchange/pull/42 :)

catermelon commented 9 years ago

yay! :tada: I commented on the other one.