1

What I am trying to do is open an xml.zip file from a website for an intro to Python project. I'm pretty sure there's nothing wrong with my code, but when I go to run the program, I get:

Traceback (most recent call last):
  File "/Users/Chris/Documents/clientDownloadFile-Handout.py", line 16, in <module>
    u = urllib2.urlopen("https://nvd.nist.gov/download/nvdcve-Recent.xml.zip")
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 154, in urlopen
    return opener.open(url, data, timeout)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 431, in open
    response = self._open(req, data)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 449, in _open
    '_open', req)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 409, in _call_chain
    result = func(*args)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 1240, in https_open
    context=self._context)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 1197, in do_open
    raise URLError(err)
URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)>

This is my code:

import urllib2

u=urllib2.urlopen("https://nvd.nist.gov/download/nvdcveRecent.xml.zip")

localFile = open('nvd.xml.zip', 'wb')
localFile.write(u.read())
localFile.close()

I've done some research, including on this site. I've tried some modifications like 'import ssl' and other 'insecure' workarounds to this problem, to no avail. I am wondering if anyone else (possibly Mac OS X El Capitan users) has encountered this, and if there is a more secure way around this?

1 Answers1

0

The URL has changed; try https://nvd.nist.gov/feeds/xml/cve/nvdcve-2.0-Recent.xml.zip instead.

Hugh Bothwell
  • 55,315
  • 8
  • 84
  • 99