Skip to content
Myr

Move SNI documentation to FAQ

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Relocate documentation on Server-Name-Indication from the advanced section to the frequently asked questions. This is minus details on enabling SNI on Python2, which is instead captured by linking to Stack Overflow.

authored by Aaron Iles · committed by Aaron Iles · parent b5b8198 · Browse files · 2 files+24 added−25 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+24 added−25 removed

  • other:+24 added−25 removed

2 files+24 added−25 removed

modified:docs/community/faq.rst+22 added
58 unmodified lines
59* Python 3.160* Python 3.261* Python 3.362* PyPy 1.96364What are "hostname doesn't match" errors?65-----------------------------------------6667These errors occur when :ref:`SSL certificate verification <verification>`68fails to match the certificate the server responds with to the hostname69Requests thinks it's contacting. If you're certain the server's SSL setup is70correct (for example, because you can visit the site with your browser) a71possible explanation is Request's is lacking Server-Name-Indication.7273`Server-Name-Indication`_, or SNI, is an official extension to SSL where the74client tells the server what hostname it is contacting. This enables `virtual75hosting`_ on SSL protected sites, the server being to able to respond with a76certificate appropriate for the hostname the client is contacting.7778Python3's SSL module includes native support for SNI. This support has not been79back ported to Python2. For information on using SNI with Requests on Python280refer to this `Stack Overflow answer`_.8182.. _`Server-Name-Indication`: https://en.wikipedia.org/wiki/Server_Name_Indication83.. _`virtual hosting`: https://en.wikipedia.org/wiki/Virtual_hosting84.. _`Stack Overflow answer`: https://stackoverflow.com/questions/18578439/using-requests-with-tls-doesnt-give-sni-support/18579484#18579484
modified:docs/user/advanced.rst+2 added-25 removed
143 unmodified lines
144 )145146 print(resp.status_code)147148.. _verification:149150SSL Cert Verification151---------------------152153Requests can verify SSL certificates for HTTPS requests, just like a web browser. To check a host's SSL certificate, you can use the ``verify`` argument::
26 unmodified lines
180181 >>> requests.get('https://kennethreitz.com', cert='/wrong_path/server.pem')182 SSLError: [Errno 336265225] _ssl.c:347: error:140B0009:SSL routines:SSL_CTX_use_PrivateKey_file:PEM lib183182Server Name Indication183----------------------184185`Server Name Indication`_, or SNI, is an official extension to SSL where the186client tells the server what hostname it is contacting. This enables `virtual187hosting`_ on SSL protected sites.188189Python3's SSL module includes native support for SNI. This support has not been190back ported to Python2. However, Requests will enable SNI support on Python2 if191the following packages are installed:192193* `pyOpenSSL`_, a Python wrapper module around the OpenSSL library.194* `ndg-httpsclient`_, enhanced HTTPS support for httplib and urllib2.195* `pyasn1`_, ASN.1 types and codecs.196197When these packages are installed, Requests will automatically indicate to the198server what hostname is being contacted. This allows the server to return the199correct server certificate for SSL certificate verification.200201.. _`Server Name Indication`: https://en.wikipedia.org/wiki/Server_Name_Indication202.. _`virtual hosting`: https://en.wikipedia.org/wiki/Virtual_hosting203.. _`pyOpenSSL`: https://pypi.python.org/pypi/pyOpenSSL204.. _`ndg-httpsclient`: https://pypi.python.org/pypi/ndg-httpsclient205.. _`pyasn1`: https://pypi.python.org/pypi/pyasn1206207185Body Content Workflow186---------------------187188By default, when you make a request, the body of the response is downloaded
494 unmodified lines