joeyespo / grip

Preview GitHub README.md files locally before committing them.
MIT License
6.45k stars 423 forks source link

Internal Server Error, HTTPSConnectionPool Error #262

Closed adoyle-h closed 6 years ago

adoyle-h commented 6 years ago
grip -b
 * Using personal access token
 * Running on http://localhost:6419/ (Press CTRL+C to quit)
 * Error: could not retrieve styles: HTTPSConnectionPool(host='github.com', port=443): Max retries exceeded with url: /joeyespo/grip (Caused by SSLError(SSLError(1, u'[SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:590)'),))
[2018-02-24 10:22:23,435] ERROR in app: Exception on / [GET]
Traceback (most recent call last):
  File "/usr/local/Cellar/grip/4.4.0/libexec/vendor/lib/python2.7/site-packages/flask/app.py", line 1982, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/Cellar/grip/4.4.0/libexec/vendor/lib/python2.7/site-packages/flask/app.py", line 1614, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/Cellar/grip/4.4.0/libexec/vendor/lib/python2.7/site-packages/flask/app.py", line 1517, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/Cellar/grip/4.4.0/libexec/vendor/lib/python2.7/site-packages/flask/app.py", line 1612, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/Cellar/grip/4.4.0/libexec/vendor/lib/python2.7/site-packages/flask/app.py", line 1598, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/local/Cellar/grip/4.4.0/libexec/lib/python2.7/site-packages/grip/app.py", line 174, in _render_page
    content = self.renderer.render(text, self.auth)
  File "/usr/local/Cellar/grip/4.4.0/libexec/lib/python2.7/site-packages/grip/renderers.py", line 77, in render
    r = requests.post(url, headers=headers, data=data, auth=auth)
  File "/usr/local/Cellar/grip/4.4.0/libexec/vendor/lib/python2.7/site-packages/requests/api.py", line 112, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/usr/local/Cellar/grip/4.4.0/libexec/vendor/lib/python2.7/site-packages/requests/api.py", line 58, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/Cellar/grip/4.4.0/libexec/vendor/lib/python2.7/site-packages/requests/sessions.py", line 508, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/Cellar/grip/4.4.0/libexec/vendor/lib/python2.7/site-packages/requests/sessions.py", line 618, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/Cellar/grip/4.4.0/libexec/vendor/lib/python2.7/site-packages/requests/adapters.py", line 506, in send
    raise SSLError(e, request=request)
SSLError: HTTPSConnectionPool(host='api.github.com', port=443): Max retries exceeded with url: /markdown/raw (Caused by SSLError(SSLError(1, u'[SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:590)'),))
127.0.0.1 - - [24/Feb/2018 10:22:23] "GET / HTTP/1.1" 500 -

The message in browser,

Internal Server Error
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

I think the connection to Github has no problem.

image

version

grip -V
Grip 4.4.0
shirohana commented 6 years ago

I have the same problem, seems related to https://developer.github.com/changes/2018-02-01-weak-crypto-removal-notice/

xavierchow commented 6 years ago

So Github just turned off the TLS1.0 and only allows TLS1.2, I fixed the issue with the openssl upgrade and python reinstallation.

brew update
brew install openssl

Then openssl version should be 1.0.x

brew update
brew install pyenv
echo 'eval "$(pyenv init -)"' >> .zshrc
source .zshrc
pyenv install 3.5.2
pyenv global 3.5.2

python --version 
python -c 'import ssl; print ssl.OPENSSL_VERSION'

After that, you can see python is using openssl 1.0.x, and if you reinstall grip everything should be good.

peterfication commented 6 years ago

Thanks a lot for this hint!

Important to add: This won't work with the Homebrew version because the Homebrew version uses an old Python (at least for me). So maybe, the Homebrew version needs an update?

cunninghamzac commented 6 years ago

I couldn't get this to work with Homebrew either. I ended up uninstalling grip in Homebrew and re-installing it with pip after I did the other steps

brew update
brew install openssl

brew update
brew install pyenv
echo 'eval "$(pyenv init -)"' >> .bash_profile
source .bash_profile
pyenv install 3.5.2
pyenv global 3.5.2
frozenpandaman commented 6 years ago

Thanks @cunninghamzac! Uninstalling it via Homebrew and using pip install grip worked for me, too.

@peterfication, Homebrew now uses 3.x as the default python.

joeyespo commented 6 years ago

Yes, this is due to GitHub shutting off weak TLS.

Thanks for chiming in, @shirohana, @xavierchow, @cunninghamzac ❤️

joeyespo commented 6 years ago

Actually, while I'm releasing new versions, I added an except block in v1.5.2 pointing people here if they happen to hit this error (f015871c4af7b8a956ed41c9b6bfdd1e6ad468cb). Can anyone still experiencing this confirm it worked / add anything missing? Thanks again!

Godron629 commented 6 years ago

@joeyespo I got your error, there is a spelling mistake in the error message though. I made a pull request https://github.com/joeyespo/grip/pull/266