404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@3.145.77.67: ~ $
3

�P\��@s�dZddlmZmZddlmZddlmZmZddlm	Z	ddl
mZddlmZddl
mZdd	lZd
dlmZd
dlmZydd
lmZWn ek
r�ddlmZYnXGdd�de�Zdd�Zd	e	jfdd�Zd	S)z�A X509Adapter for use with the requests library.

This file contains an implementation of the X509Adapter that will
allow users to authenticate a request using an arbitrary
X.509 certificate without needing to convert it to a .pem file

�)�PKey�X509)�x509)�load_pem_private_key�load_der_private_key)�Encoding)�default_backend)�datetime)�HTTPAdapterN�)�PyOpenSSLContext)�
exceptions)�PROTOCOL_TLS)�PROTOCOL_SSLv23cs@eZdZdZ�fdd�Z�fdd�Z�fdd�Zdd	�Z�ZS)
�X509Adaptera_Adapter for use with X.509 certificates.

    Provides an interface for Requests sessions to contact HTTPS urls and
    authenticate  with an X.509 cert by implementing the Transport Adapter
    interface. This class will need to be manually instantiated and mounted
    to the session

    :param pool_connections: The number of urllib3 connection pools to
           cache.
    :param pool_maxsize: The maximum number of connections to save in the
            pool.
    :param max_retries: The maximum number of retries each connection
        should attempt. Note, this applies only to failed DNS lookups,
        socket connections and connection timeouts, never to requests where
        data has made it to the server. By default, Requests does not retry
        failed connections. If you need granular control over the
        conditions under which we retry a request, import urllib3's
        ``Retry`` class and pass that instead.
    :param pool_block: Whether the connection pool should block for
            connections.

    :param bytes cert_bytes:
        bytes object containing contents of a cryptography.x509Certificate
        object using the encoding specified by the ``encoding`` parameter.
    :param bytes pk_bytes:
        bytes object containing contents of a object that implements
        ``cryptography.hazmat.primitives.serialization.PrivateFormat``
        using the encoding specified by the ``encoding`` parameter.
    :param password:
        string or utf8 encoded bytes containing the passphrase used for the
        private key. None if unencrypted. Defaults to None.
    :param encoding:
        Enumeration detailing the encoding method used on the ``cert_bytes``
        parameter. Can be either PEM or DER. Defaults to PEM.
    :type encoding:
        :class: `cryptography.hazmat.primitives.serialization.Encoding`

    Usage::

      >>> import requests
      >>> from requests_toolbelt.adapters.x509 import X509Adapter
      >>> s = requests.Session()
      >>> a = X509Adapter(max_retries=3,
                cert_bytes=b'...', pk_bytes=b'...', encoding='...'
      >>> s.mount('https://', a)
    cs�|j�|jdd�}|jdd�}|jdd�}|jdtj�}d}|dksRt|t�rZtd��|dksnt|t�rvtd��t|t�r�|}n|r�|jd�}t||||�|_	t
t|�j||�dS)N�
cert_bytes�pk_bytes�password�encodingzXInvalid cert content provided. You must provide an X.509 cert formatted as a byte array.z_Invalid private key content provided. You must provide a private key formatted as a byte array.�utf8)
�_check_version�popr�PEM�
isinstance�bytes�
ValueError�encode�create_ssl_context�ssl_context�superr�__init__)�self�args�kwargsrrrrZpassword_bytes)�	__class__��/usr/lib/python3.6/x509.pyr Ss"


zX509Adapter.__init__cs"|jr|j|d<tt|�j||�S)Nr)rrr�init_poolmanager)r!r"r#)r$r%r&r'os
zX509Adapter.init_poolmanagercs"|jr|j|d<tt|�j||�S)Nr)rrr�proxy_manager_for)r!r"r#)r$r%r&r(ts
zX509Adapter.proxy_manager_forcCstdkrtjdjtj���dS)NzaThe X509Adapter requires at least Requests 2.12.0 to be installed. Version {0} was found instead.)r�excZVersionMismatchError�format�requests�__version__)r!r%r%r&ryszX509Adapter._check_version)	�__name__�
__module__�__qualname__�__doc__r r'r(r�
__classcell__r%r%)r$r&r#s
.rcCs4tj�}|j|ks|j|kr0tdj|j|j���dS)z4Verify that the supplied client cert is not invalid.z`Client certificate expired: Not After: {0:%Y-%m-%d %H:%M:%SZ} Not Before: {1:%Y-%m-%d %H:%M:%SZ}N)r	ZutcnowZnot_valid_afterZnot_valid_beforerr*)�certZnowr%r%r&�check_cert_dates�sr3cCs�t�}d}d}|tjkr2tj||�}t|||�}n,|tjkrVtj||�}t|||�}nt	d��|od|snt	d��t
|�tt�}|j
jtj|��|j
jtj|��|S)a�Create an SSL Context with the supplied cert/password.

    :param cert_bytes array of bytes containing the cert encoded
           using the method supplied in the ``encoding`` parameter
    :param pk_bytes array of bytes containing the private key encoded
           using the method supplied in the ``encoding`` parameter
    :param password array of bytes containing the passphrase to be used
           with the supplied private key. None if unencrypted.
           Defaults to None.
    :param encoding ``cryptography.hazmat.primitives.serialization.Encoding``
            details the encoding method used on the ``cert_bytes``  and
            ``pk_bytes`` parameters. Can be either PEM or DER.
            Defaults to PEM.
    Nz-Invalid encoding provided: Must be PEM or DERz3Cert and key could not be parsed from provided data)rrrrZload_pem_x509_certificaterZDERZload_der_x509_certificaterrr3r�PROTOCOLZ_ctxZuse_certificaterZfrom_cryptographyZuse_privatekeyrZfrom_cryptography_key)Z	cert_byesrrrZbackendr2�keyrr%r%r&r�s"

r)r0ZOpenSSL.cryptorrZcryptographyrZ,cryptography.hazmat.primitives.serializationrrrZcryptography.hazmat.backendsrr	Zrequests.adaptersr
r+Z_compatr�r
r)Z_sslrr4�ImportErrorrrr3rrr%r%r%r&�<module>s$`

Filemanager

Name Type Size Permission Actions
__init__.cpython-36.opt-1.pyc File 460 B 0644
__init__.cpython-36.pyc File 460 B 0644
appengine.cpython-36.opt-1.pyc File 7.23 KB 0644
appengine.cpython-36.pyc File 7.23 KB 0644
fingerprint.cpython-36.opt-1.pyc File 1.68 KB 0644
fingerprint.cpython-36.pyc File 1.68 KB 0644
host_header_ssl.cpython-36.opt-1.pyc File 1.32 KB 0644
host_header_ssl.cpython-36.pyc File 1.32 KB 0644
socket_options.cpython-36.opt-1.pyc File 4.01 KB 0644
socket_options.cpython-36.pyc File 4.01 KB 0644
source.cpython-36.opt-1.pyc File 2.74 KB 0644
source.cpython-36.pyc File 2.74 KB 0644
ssl.cpython-36.opt-1.pyc File 2.44 KB 0644
ssl.cpython-36.pyc File 2.44 KB 0644
x509.cpython-36.opt-1.pyc File 6.42 KB 0644
x509.cpython-36.pyc File 6.42 KB 0644