Reputation: 1439
I am making geocoding requests to googles api using requests:
geo_url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' + geo_address + '&key=' + GOOGLE_API_KEY
geo_response = requests.get(url=geo_url, verify=False)
geo = geo_response.json()
In my cloud9 IDE it works semalessly.
On my Ubuntu Server with Apache and mod_wsgi it works SOMETIMES, but often it fails with an error in Apaches error.log:
File "/var/virtualenv/primo/lib/python2.7/site-packages/django/utils/log.py", line 129, in emit
self.send_mail(subject, message, fail_silently=True, html_message=html_message)
File "/var/virtualenv/primo/lib/python2.7/site-packages/django/utils/log.py", line 132, in send_mail
mail.mail_admins(subject, message, *args, connection=self.connection(), **kwargs)
File "/var/virtualenv/primo/lib/python2.7/site-packages/django/core/mail/__init__.py", line 98, in mail_admins
mail.send(fail_silently=fail_silently)
File "/var/virtualenv/primo/lib/python2.7/site-packages/django/core/mail/message.py", line 303, in send
return self.get_connection(fail_silently).send_messages([self])
File "/var/virtualenv/primo/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 100, in send_messages
new_conn_created = self.open()
File "/var/virtualenv/primo/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 64, in open
self.connection.starttls(keyfile=self.ssl_keyfile, certfile=self.ssl_certfile)
File "/usr/lib/python2.7/smtplib.py", line 649, in starttls
self.sock = ssl.wrap_socket(self.sock, keyfile, certfile)
File "/usr/lib/python2.7/ssl.py", line 487, in wrap_socket
ciphers=ciphers)
File "/usr/lib/python2.7/ssl.py", line 243, in __init__
self.do_handshake()
File "/usr/lib/python2.7/ssl.py", line 405, in do_handshake
self._sslobj.do_handshake()
error: [Errno 0] Error
I do not understand what is going wrong. Can somebody point me in the correct direction, please?
Upvotes: 1
Views: 600
Reputation: 1439
After a long research I found out its a bug in cryptography module.
See: https://github.com/pyca/cryptography/issues/2299
workaround: place WSGIApplicationGroup %{GLOBAL}
in apache virtualhost configuration e.g.
<Directory /var/www/path/to/wsgi>
<Files wsgi.py>
Require all granted
</Files>
WSGIApplicationGroup %{GLOBAL}
</Directory>
Upvotes: 1