OpenQuizz
Une application de gestion des contenus pédagogiques
pip._vendor.urllib3.contrib.securetransport Namespace Reference

Data Structures

class  SecureTransportContext
 
class  WrappedSocket
 

Functions

def inject_into_urllib3 ()
 
def extract_from_urllib3 ()
 
def makefile (self, mode, bufsize=-1)
 
def makefile (self, mode="r", buffering=None, *args, **kwargs)
 

Variables

 HAS_SNI
 
 orig_util_HAS_SNI
 
 orig_util_SSLContext
 
 SSL_WRITE_BLOCKSIZE
 
 CIPHER_SUITES
 

Detailed Description

SecureTranport support for urllib3 via ctypes.

This makes platform-native TLS available to urllib3 users on macOS without the
use of a compiler. This is an important feature because the Python Package
Index is moving to become a TLSv1.2-or-higher server, and the default OpenSSL
that ships with macOS is not capable of doing TLSv1.2. The only way to resolve
this is to give macOS users an alternative solution to the problem, and that
solution is to use SecureTransport.

We use ctypes here because this solution must not require a compiler. That's
because pip is not allowed to require a compiler either.

This is not intended to be a seriously long-term solution to this problem.
The hope is that PEP 543 will eventually solve this issue for us, at which
point we can retire this contrib module. But in the short term, we need to
solve the impending tire fire that is Python on Mac without this kind of
contrib module. So...here we are.

To use this module, simply import and inject it::

    import urllib3.contrib.securetransport
    urllib3.contrib.securetransport.inject_into_urllib3()

Happy TLSing!

This code is a bastardised version of the code found in Will Bond's oscrypto
library. An enormous debt is owed to him for blazing this trail for us. For
that reason, this code should be considered to be covered both by urllib3's
license and by oscrypto's:

.. code-block::

    Copyright (c) 2015-2016 Will Bond <will@wbond.net>

    Permission is hereby granted, free of charge, to any person obtaining a
    copy of this software and associated documentation files (the "Software"),
    to deal in the Software without restriction, including without limitation
    the rights to use, copy, modify, merge, publish, distribute, sublicense,
    and/or sell copies of the Software, and to permit persons to whom the
    Software is furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
    DEALINGS IN THE SOFTWARE.

Function Documentation

◆ extract_from_urllib3()

def pip._vendor.urllib3.contrib.securetransport.extract_from_urllib3 ( )
Undo monkey-patching by :func:`inject_into_urllib3`.

◆ inject_into_urllib3()

def pip._vendor.urllib3.contrib.securetransport.inject_into_urllib3 ( )
Monkey-patch urllib3 with SecureTransport-backed SSL-support.

◆ makefile() [1/2]

def pip._vendor.urllib3.contrib.securetransport.makefile (   self,
  mode,
  bufsize = -1 
)

◆ makefile() [2/2]

def pip._vendor.urllib3.contrib.securetransport.makefile (   self,
  mode = "r",
  buffering = None,
args,
**  kwargs 
)

Variable Documentation

◆ CIPHER_SUITES

CIPHER_SUITES

◆ HAS_SNI

HAS_SNI

◆ orig_util_HAS_SNI

orig_util_HAS_SNI

◆ orig_util_SSLContext

orig_util_SSLContext

◆ SSL_WRITE_BLOCKSIZE

SSL_WRITE_BLOCKSIZE