Qucs-S S-parameter Viewer & RF Synthesis Tools
Loading...
Searching...
No Matches
Classes | Functions | Variables
pip._vendor.urllib3.contrib.securetransport Namespace Reference

Classes

class  SecureTransportContext
 
class  WrappedSocket
 

Functions

 inject_into_urllib3 ()
 
 extract_from_urllib3 ()
 
 _read_callback (connection_id, data_buffer, data_length_pointer)
 
 _write_callback (connection_id, data_buffer, data_length_pointer)
 
 makefile (self, mode, bufsize=-1)
 
 makefile (self, mode="r", buffering=None, *args, **kwargs)
 

Variables

 _fileobject = None
 
bool HAS_SNI = True
 
bool orig_util_HAS_SNI = util.HAS_SNI
 
 orig_util_SSLContext = util.ssl_.SSLContext
 
 _connection_refs = weakref.WeakValueDictionary()
 
 _connection_ref_lock = threading.Lock()
 
int SSL_WRITE_BLOCKSIZE = 16384
 
list CIPHER_SUITES
 
dict _protocol_to_min_max
 
 _read_callback_pointer = Security.SSLReadFunc(_read_callback)
 
 _write_callback_pointer = Security.SSLWriteFunc(_write_callback)
 
 makefile
 

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 pip._vendor.urllib3.contrib.securetransport as securetransport
    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

◆ _read_callback()

pip._vendor.urllib3.contrib.securetransport._read_callback (   connection_id,
  data_buffer,
  data_length_pointer 
)
protected
SecureTransport read callback. This is called by ST to request that data
be returned from the socket.

◆ _write_callback()

pip._vendor.urllib3.contrib.securetransport._write_callback (   connection_id,
  data_buffer,
  data_length_pointer 
)
protected
SecureTransport write callback. This is called by ST to request that data
actually be sent on the network.

◆ extract_from_urllib3()

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

◆ inject_into_urllib3()

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

Variable Documentation

◆ _protocol_to_min_max

dict pip._vendor.urllib3.contrib.securetransport._protocol_to_min_max
protected
Initial value:
1= {
2 util.PROTOCOL_TLS: (SecurityConst.kTLSProtocol1, SecurityConst.kTLSProtocol12),
3 PROTOCOL_TLS_CLIENT: (SecurityConst.kTLSProtocol1, SecurityConst.kTLSProtocol12),
4}