Your IP : 13.58.53.112


Current Path : /opt/alt/python34/lib/python3.4/site-packages/setuptools/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib/python3.4/site-packages/setuptools/__pycache__/ssl_support.cpython-34.pyc

�
M�Re��@scddlZddlZddlZddlZddlZddlmZmZddlmZyddl	Z	Wne
k
r�dZ	YnXdddddgZd	j�j
�ZeZZxpd
ddgfd
ddgffD]J\ZZx;eD]3Zyedeef�Wq�e
k
r(Yq�Xq�Wq�We	dk	oLeeefkZyddl	mZmZWnWe
k
r�y$ddlmZddlmZWne
k
r�dZdZYnXYnXes�Gdd�de�Znesddd�Zdd�ZnGdd�de�ZGdd�de�Zddd�Zdadd �Z d!d�Z!dS)"�N)�ResolutionError�ExtractionError)�urllib2�VerifyingHTTPSHandler�find_ca_bundle�is_available�
cert_paths�
opener_forz�
/etc/pki/tls/certs/ca-bundle.crt
/etc/ssl/certs/ca-certificates.crt
/usr/share/ssl/certs/ca-bundle.crt
/usr/local/share/certs/ca-root.crt
/etc/ssl/cert.pem
/System/Library/OpenSSL/certs/cert.pem
�HTTPSHandlerrzurllib.request�HTTPSConnection�httplibzhttp.clientzfrom %s import %s)�CertificateError�match_hostname)r
)rc@seZdZdS)r
N)�__name__�
__module__�__qualname__�rr�1/tmp/pip-l4uy7dan-build/setuptools/ssl_support.pyr
8sr
�c
CsXg}|sdS|jd�}|d}|dd�}|jd�}||krmtdt|���n|s�|j�|j�kS|dkr�|jd�nY|jd	�s�|jd	�r�|jtj|��n"|jtj|�j	d
d��x$|D]}|jtj|��qWtj
dd
j|�dtj�}	|	j
|�S)zpMatching according to RFC 6125, section 6.4.3

        http://tools.ietf.org/html/rfc6125#section-6.4.3
        F�.rrN�*z,too many wildcards in certificate DNS name: z[^.]+zxn--z\*z[^.]*z\Az\.z\Z)�split�countr
�repr�lower�append�
startswith�re�escape�replace�compile�join�
IGNORECASE�match)
�dn�hostname�
max_wildcards�pats�parts�leftmost�	remainder�	wildcards�frag�patrrr�_dnsname_match<s*
"
&r.cCs[|std��ng}|jdf�}xC|D];\}}|dkr4t||�r_dS|j|�q4q4W|s�xc|jdf�D]L}xC|D];\}}|dkr�t||�r�dS|j|�q�q�Wq�Wnt|�dkrtd|d	jtt|��f��n;t|�dkrKtd
||df��ntd��dS)
a=Verify that *cert* (in decoded format as returned by
        SSLSocket.getpeercert()) matches the *hostname*.  RFC 2818 and RFC 6125
        rules are followed, but IP addresses are not accepted for *hostname*.

        CertificateError is raised on failure. On success, the function
        returns nothing.
        zempty or no certificate�subjectAltName�DNSN�subject�
commonNamerz&hostname %r doesn't match either of %sz, zhostname %r doesn't match %rrz=no appropriate commonName or subjectAltName fields were found)	�
ValueError�getr.r�lenr
r!�mapr)�certr%�dnsnames�san�key�value�subrrrrps.%rc@s.eZdZdZdd�Zdd�ZdS)rz=Simple verifying handler: no auth, subclasses, timeouts, etc.cCs||_tj|�dS)N)�	ca_bundler
�__init__)�selfr=rrrr>�s	zVerifyingHTTPSHandler.__init__cs�j�fdd�|�S)Ncst|�j|�S)N)�VerifyingHTTPSConnr=)�host�kw)r?rr�<lambda>�sz2VerifyingHTTPSHandler.https_open.<locals>.<lambda>)�do_open)r?�reqr)r?r�
https_open�sz VerifyingHTTPSHandler.https_openN)rrr�__doc__r>rFrrrrr�sc@s.eZdZdZdd�Zdd�ZdS)r@z@Simple verifying connection: no auth, subclasses, timeouts, etc.cKs tj|||�||_dS)N)rr>r=)r?rAr=rBrrrr>�szVerifyingHTTPSConn.__init__cCs�tj|j|jft|dd��}t|d�rat|dd�ra||_|j�ntj	|dtj
d|j�|_yt|jj
�|j�Wn5tk
r�|jjtj�|jj��YnXdS)N�source_address�_tunnel�_tunnel_host�	cert_reqs�ca_certs)�socket�create_connectionrA�port�getattr�hasattr�sockrI�ssl�wrap_socket�
CERT_REQUIREDr=r�getpeercertr
�shutdown�	SHUT_RDWR�close)r?rRrrr�connect�s$!	


zVerifyingHTTPSConn.connectN)rrrrGr>rZrrrrr@�sr@cCstjt|pt���jS)z@Get a urlopen() replacement that uses ca_bundle for verification)r�build_openerrr�open)r=rrrr	�scsxtdk	rtjSyddlm�Wntk
r?dSYnXG�fdd�d��}|dddg�atjS)Nr)�CertFilecs(eZdZff�fdd�ZdS)z$get_win_certfile.<locals>.MyCertFilecsL�j|�x|D]}|j|�qW|j|�tj|j�dS)N)r>ZaddstoreZaddcerts�atexit�registerrY)r?�stores�certs�store)r]rrr>�s



z-get_win_certfile.<locals>.MyCertFile.__init__N)rrrr>r)r]rr�
MyCertFile�srcr`�CA�ROOT)�	_wincerts�nameZwincertstorer]�ImportError)rcr)r]r�get_win_certfile�s
	ric
Cswtjdkrt�Sx$tD]}tjj|�r|SqWytjdd�SWntt	t
fk
rrdSYnXdS)z*Return an existing CA bundle path, or None�ntZcertifiz
cacert.pemN)�osrgrir�path�isfile�
pkg_resources�resource_filenamerhrr)Z	cert_pathrrrr�s
)"rkrMr^rrnrrZsetuptools.compatrrSrh�__all__�striprr�objectr
r�what�where�module�execrr
rZbackports.ssl_match_hostnamer3r.rr@r	rfrirrrrr�<module>sV
	






4)


?>