0

I've been trying to do a simple authorization requests through python (2.7 and 3.5) e.g.

import requests
requests.get('https://sub-domain.chargify.com/subscriptions.json', auth=('my-authorization-key', 'x'))

and i get the following error

requests.exceptions.ConnectionError: HTTPSConnectionPool(host='sub-domain.chargify.com', port=443): Max retries exceeded with url: /subscriptions.json (Caused by <class 'socket.error'>: [Errno 54] Connection reset by peer)

but if i do a curl call everything works just fine

curl -u my-authorization-key:x https://sub-domain.chargify.com/subscriptions.json

I even tried to go the urllib2 route getting similar responses than requests. Asked a friend to run the requests code for me on his computer and it worked just fine. The only difference was that he was using a newer version of requests so i updated mine to his version didn't work. Went to a server and tried exactly the same steps mentioned above and everything works fine, no errors using requests is only in my mac. I've updated python 2.7 and 3.6 on my machine thinking that maybe that was the cause but still have the same results

any idea on what could it be?

efx
  • 63
  • 9
  • openssl version? – oshaiken Jun 01 '17 at 20:42
  • @oshaiken mac's default **OpenSSL 0.9.8zh 14 Jan 2016** – efx Jun 01 '17 at 20:51
  • I have had problems with requests, and after upgrading opens ssl to 1.0.2, did not have problems. – oshaiken Jun 01 '17 at 20:53
  • From requests dependencies. win-inet-pton; sys_platform == "win32" and (python_version == "2.7" or python_version == "2.6") and extra == 'socks' PySocks (!=1.5.7,>=1.5.6); extra == 'socks' pyOpenSSL (>=0.14); extra == 'security' idna (>=2.0.0); extra == 'security' cryptography (>=1.3.4); extra == 'security' urllib3 (>=1.21.1,<1.22) idna (<2.6,>=2.5) chardet (<3.1.0,>=3.0.2) certifi (>=2017.4.17) --> pyOpenSSL, supported OpenSSL versions are 1.0.1 1.0.2 1.1.0 – oshaiken Jun 01 '17 at 21:08
  • @oshaiken updated openssl that fixed the issuem can u put it as an answer to give u credit. – efx Jun 02 '17 at 02:02

1 Answers1

0

From requests dependencies: pyOpenSSL, supported OpenSSL versions are 1.0.1 1.0.2 1.1.0

Check openssl version and update, then symlink it.

openssl version
brew update
brew install openssl
brew link --force openssl
oshaiken
  • 2,593
  • 1
  • 15
  • 25
  • `brew link --force openssl` doesn't work you have to manually do the linking [Extra Steps](https://stackoverflow.com/questions/38670295/homebrew-refusing-to-link-openssl) per *rorykoehler* answer – efx Jun 02 '17 at 20:37