SSL23_GET_SERVER_HELLO: tlsv1 alert internal error (SNI) in Python 2.7.6

SSL23_GET_SERVER_HELLO: tlsv1 alert internal error (SNI) in Python 2.7.6

會發生在 Python 2.7.6 連 CloudFlare HTTPS 的時候
似乎是因為 2.7.6 不支援 Server-Name-Indication (SNI)
Python 2.7.9 之後才支援

相關錯誤:

SSL routines: SSL23_GET_SERVER_HELLO: tlsv1 alert internal error
SSLError: bad handshake: SysCallError(32, 'EPIPE')

解決辦法:

$ sudo apt-get install libffi-dev libssl-dev
$ pip install -U urllib3[secure] ndg-httpsclient pyasn1

ref:
https://stackoverflow.com/questions/18578439/using-requests-with-tls-doesnt-give-sni-support/
http://docs.python-requests.org/en/master/community/faq/
https://github.com/kennethreitz/requests/issues/749
https://github.com/kennethreitz/requests/pull/1347