3
O6b                 @   s   d Z ddlZddlZeedejZeeddZeeddZeeddZ	eeddZ
eedd	Zd	ZejZy8dd
lmZ eedrddlmZ ejdd dkZW n0 ek
r   ddlmZ G dd deZY nX dS )z!A fake SSLContext implementation.    NPROTOCOL_TLS_CLIENTOP_NO_SSLv2OP_NO_SSLv3OP_NO_COMPRESSIONOP_NO_RENEGOTIATIONHAS_SNIF)
SSLContextVERIFY_CRL_CHECK_LEAF)r	            )ConfigurationErrorc               @   s`   e Zd ZdZdZdd Zed	d
 Zdd Zdd Z	eee	Z
dddZdddZdddZdS )r   a  A fake SSLContext.

        This implements an API similar to ssl.SSLContext from python 3.2
        but does not implement methods or properties that would be
        incompatible with ssl.wrap_socket from python 2.7 < 2.7.9.

        You must pass protocol which must be one of the PROTOCOL_* constants
        defined in the ssl module. ssl.PROTOCOL_SSLv23 is recommended for maximum
        interoperability.
        _cafile	_certfile_keyfile	_protocol_verify_modec             C   s$   d | _ d | _d | _|| _tj| _d S )N)r   r   r   r   _ssl	CERT_NONEr   )selfprotocol r   R/var/www/html/sandeepIITI/myenv/lib/python3.6/site-packages/pymongo/ssl_context.py__init__E   s
    zSSLContext.__init__c             C   s   | j S )zpThe protocol version chosen when constructing the context.
            This attribute is read-only.
            )r   )r   r   r   r   r   L   s    zSSLContext.protocolc             C   s   | j S )zWhether to try to verify other peers' certificates and how to
            behave if verification fails. This attribute must be one of
            ssl.CERT_NONE, ssl.CERT_OPTIONAL or ssl.CERT_REQUIRED.
            )r   )r   r   r   r   Z__get_verify_modeS   s    zSSLContext.__get_verify_modec             C   s
   || _ dS )zSetter for verify_mode.N)r   )r   valuer   r   r   Z__set_verify_modeZ   s    zSSLContext.__set_verify_modeNc             C   s    |dk	rt d|| _|| _dS )a  Load a private key and the corresponding certificate. The certfile
            string must be the path to a single file in PEM format containing the
            certificate as well as any number of CA certificates needed to
            establish the certificate's authenticity. The keyfile string, if
            present, must point to a file containing the private key. Otherwise
            the private key will be taken from certfile as well.
            NzZSupport for ssl_pem_passphrase requires python 2.7.9+ (pypy 2.5.1+), python 3 or PyOpenSSL)r   r   r   )r   certfilekeyfilepasswordr   r   r   load_cert_chain`   s
    zSSLContext.load_cert_chainc             C   s
   || _ dS )zLoad a set of "certification authority"(CA) certificates used to
            validate other peers' certificates when `~verify_mode` is other than
            ssl.CERT_NONE.
            N)r   )r   cafiledummyr   r   r   load_verify_locationsp   s    z SSLContext.load_verify_locationsFTc             C   s&   t j|| j| j|| j| j| j||d	S )z`Wrap an existing Python socket sock and return an ssl.SSLSocket
            object.
            )r   r   server_side	cert_reqsssl_versionca_certsdo_handshake_on_connectsuppress_ragged_eofs)r   wrap_socketr   r   r   r   r   )r   sockr"   r&   r'   r    r   r   r   r(   w   s    
zSSLContext.wrap_socket)r   r   r   r   r   )NN)NN)FTTN)__name__
__module____qualname____doc__	__slots__r   propertyr   Z_SSLContext__get_verify_modeZ_SSLContext__set_verify_modeverify_moder   r!   r(   r   r   r   r   r   6   s   
 


  r   )r   r   )r-   sslr   sys_sysgetattrPROTOCOL_SSLv23r   r   r   r   r   IS_PYOPENSSLSSLErrorr   hasattrr	   version_infoZCHECK_HOSTNAME_SAFEImportErrorZpymongo.errorsr   objectr   r   r   r   <module>   s$   
