SSLError name mismatch
phundisk opened this issue · 3 comments
I am currently seeing this only on my CentOS 5.6 machine with python2.6 but no error on OS X which I originally developed my script on. This seems to be failing on the get_collectors method on line containing "collectors = coll.get_collectors()"
$ python26 sumo_standard.py
Traceback (most recent call last):
File "sumo_standard.py", line 24, in
collectors = coll.get_collectors()
File "/usr/lib/python2.6/site-packages/sumologic/collectors.py", line 55, in get_collectors
request = requests.get(self.url, params=options, auth=self.auth)
File "/usr/lib/python2.6/site-packages/requests/api.py", line 54, in get
return request('get', url, *_kwargs)
File "/usr/lib/python2.6/site-packages/requests/safe_mode.py", line 37, in wrapped
return function(method, url, *_kwargs)
File "/usr/lib/python2.6/site-packages/requests/api.py", line 42, in request
return s.request(method=method, url=url, **kwargs)
File "/usr/lib/python2.6/site-packages/requests/sessions.py", line 230, in request
r.send(prefetch=prefetch)
File "/usr/lib/python2.6/site-packages/requests/models.py", line 613, in send
raise SSLError(e)
requests.exceptions.SSLError: hostname 'api.sumologic.com' doesn't match u'service.sumologic.com'
author = 'xxx'
import sumologic.client
import sumologic.search
import sumologic.collectors
import requests
import json
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
import smtplib
ACCESS_ID='xxxx'
ACCESS_KEY='xxx'
Dev Access Credentials
ACCESS_ID='xxx'
ACCESS_KEY='xxx'
Production Access Credentials
ACCESS_ID='xx'
ACCESS_KEY='xxx'
conn = sumologic.client.Client(auth=(ACCESS_ID, ACCESS_KEY))
coll = sumologic.collectors.Collectors(conn)
collectors = coll.get_collectors()
I'll check on this later tonight.
What if you temporarily change this line:
conn = sumologic.client.Client(auth=(ACCESS_ID, ACCESS_KEY)
to
conn = sumologic.client.Client(auth=(ACCESS_ID, ACCESS_KEY, domain='service.sumologic.com')
Sijis
My apologies for not being able to look at this sooner.
I can validate that this does occur in centos 5.9 (i know you were using 5.6). Interestingly enough, in centos 6.x the error does not pop up.
The temporary fix is to modify this line:
https://github.com/sijis/sumologic-python/blob/master/sumologic/collectors.py#L55
so it looks like this:
request = requests.get(self.url, params=options, auth=self.auth, verify=False)
I'll have to figure out a longer term strategy to inject the verify parameter to all requests calls as to no need to hack the library directly.
Sijis
@yowayb - I'm seeing the issue in the sumologic-sdk library you are working on too.
>>> from sumologic import SumoLogic
>>> sumo = SumoLogic('myusername', "mypassword")
>>> sumo.collectors()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "sumologic/sumologic.py", line 51, in collectors
r = self.get('/collectors', params)
File "sumologic/sumologic.py", line 18, in get
return self.session.get(self.endpoint + method, params=params)
File "/usr/lib/python2.6/site-packages/requests-2.4.3-py2.6.egg/requests/sessions.py", line 469, in get
return self.request('GET', url, **kwargs)
File "/usr/lib/python2.6/site-packages/requests-2.4.3-py2.6.egg/requests/sessions.py", line 457, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python2.6/site-packages/requests-2.4.3-py2.6.egg/requests/sessions.py", line 569, in send
r = adapter.send(request, **kwargs)
File "/usr/lib/python2.6/site-packages/requests-2.4.3-py2.6.egg/requests/adapters.py", line 420, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: hostname 'api.sumologic.com' doesn't match u'service.sumologic.com'
>>>
(i would have filed a issue on that repo, but its not enabled)