I'm making a Django website and am fairly new. In this webapp I need to use this API which will spit out an xml file with the requested data from the database. Basically the API URL is:
https://adminuser:[email protected]/database.getdata?arg=1&arg2=0
So in my python views.py I have:
def fetch_xml(url):
import urllib
import xml.etree.cElementTree as xml_parser
u = urllib.URLopener(None)
usock = u.open(url)
rawdata = usock.read()
usock.close()
return xml_parser.fromstring(rawdata)
Which I got from http://www.webmonkey.com/2010/02/integrate_web_apis_into_your_django_site/
However, I received the following error right at the line usock = u.open(url)
IOError at /webapp/
[Errno socket error] [Errno 1] _ssl.c:480: error:140943FC:SSL routines:SSL3_READ_BYTES:sslv3 alert bad record mac
I read on the urllib
documentation that an IOError is thrown if the connection cannot be made.
http://docs.python.org/library/urllib.html
Also, on Wikipedia a "Bad record MAC" fatal alert means "Possibly a bad SSL implementation, or payload has been tampered with. E.g., FTP firewall rule on FTPS server."
But what I don't understand is that when I paste the URL into my browser it works fine and spits out an XML file.
I also thought (as a long shot) it might be my Apache installation so I checked that mod_ssl was being loaded by typing apachectl -t -D DUMP_MODULES
in terminal and it is loaded as shared.
Any ideas would be greatly appreciated. Thanks!