Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using requests with TLS doesn't give SNI support

I'm using requests to communicate with a django app but

When I try

requests.get('https://mysite.com', verify=True) 

I get the error:

hostname 'mysite.com' doesn't match either of '*.myhost.com', 'myhost.com'

However, when I look at the browser, or http://www.digicert.com/help/ the certificate looks fine and dandy.

My host suggested it was the lack of SNI support from requests (and Github seems to confirm that https://github.com/kennethreitz/requests/issues/749 ). Has anyone found a work-around using requests?

like image 352
Massagran Avatar asked Sep 02 '13 17:09

Massagran


Video Answer


2 Answers

The current version of Requests should be just fine with SNI. Further down the GitHub issue you can see the requirements:

  • pyOpenSSL
  • ndg-httpsclient
  • pyasn1

Try installing those packages and then give it another shot.

EDIT: As of Requests v2.12.1, ndg-httpsclient and pyasn1 are no longer required. The full list of required packages is now:

  • pyOpenSSL
  • idna
like image 89
Lukasa Avatar answered Sep 24 '22 02:09

Lukasa


In order for me to get the accepted answer to work, I had to install a bunch of other packages, in this order:

  • yum install libffi-devel
  • yum install gcc
  • yum install openssl-devel
  • pip install urllib3
  • pip install pyopenssl
  • pip install ndg-httpsclient
  • pip install pyasn1
like image 39
Shane N Avatar answered Sep 21 '22 02:09

Shane N