Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Certificate error from urllib #22

Open
micromouseonline opened this issue Mar 7, 2019 · 5 comments
Open

Certificate error from urllib #22

micromouseonline opened this issue Mar 7, 2019 · 5 comments
Labels
enhancement New feature or request good first issue Good for newcomers
Milestone

Comments

@micromouseonline
Copy link

micromouseonline commented Mar 7, 2019

When I do the install as directed and then run mmsim, I get an error. Specifically, this error:

  urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056)>

The reason is that the Python installer on MacOs may not have run the certificate commands.

This question on StackExchange has the answer:

https://stackoverflow.com/questions/44649449/brew-installation-of-python-3-6-1-ssl-certificate-verify-failed-certificate/44649450#44649450

@micromouseonline
Copy link
Author

Just to be clear, this is not an issue with the mmsim code. The problem is with the way that Python may be installed under MacOS. I used the pkg installation from python.org.

The issue can be demonstrated from the Python shell:

  Python 3.7.2 (v3.7.2:9a3ffc0492, Dec 24 2018, 02:44:43) 
  [Clang 6.0 (clang-600.0.57)] on darwin
  Type "help", "copyright", "credits" or "license" for more information.
  >>> from urllib.request import urlretrieve
  >>> url = 'https://github.com/micromouseonline/mazefiles/'\
  ...         'archive/master.tar.gz'
  >>> url
  'https://github.com/micromouseonline/mazefiles/archive/master.tar.gz'
  >>> reveal_tar, headers = urlretrieve(url)
  Traceback (most recent call last):
    File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 1317, in do_open
    encode_chunked=req.has_header('Transfer-encoding'))
    File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1229, in request
    self._send_request(method, url, body, headers, encode_chunked)
    File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1275, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
    File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1224, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
    File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1016, in _send_output
    self.send(msg)
    File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 956, in send
    self.connect()
    File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1392, in connect
    server_hostname=server_hostname)
    File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 412, in wrap_socket
    session=session
    File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 853, in _create
    self.do_handshake()
    File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 1117, in do_handshake
    self._sslobj.do_handshake()
  ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056)

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 247, in urlretrieve
    with contextlib.closing(urlopen(url, data)) as fp:
    File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
    File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 525, in open
    response = self._open(req, data)
    File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 543, in _open
    '_open', req)
    File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 503, in _call_chain
    result = func(*args)
    File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 1360, in https_open
    context=self._context, check_hostname=self._check_hostname)
    File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 1319, in do_open
    raise URLError(err)
  urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056)>
  >>> exit()

@Peque
Copy link
Member

Peque commented Mar 8, 2019

Oh, I understand. I cannot fix that. 😅

However, if you confirm that you could use requests to get content from an HTTPS source (i.e.: a GitHub page) without having those issues, I would not mind adding that extra dependency. Apparently they use certifi package, which may not require you to have any special system-wide configuration.

@micromouseonline
Copy link
Author

micromouseonline commented Mar 8, 2019 via email

@Peque Peque added enhancement New feature or request good first issue Good for newcomers labels Jul 1, 2019
@Peque Peque added this to the 0.2.0 milestone Jul 1, 2019
@Peque
Copy link
Member

Peque commented Jul 1, 2019

@micromouseonline I will leave this open, as I think a note in the README file could be appropriate, as you suggested.

Do not know whether I will add it soon or not, but definitely some day! 😄

Pull requests accepted too. 😜

@Peque Peque reopened this Jul 1, 2019
@micromouseonline
Copy link
Author

micromouseonline commented Jul 1, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants