Your IP : 3.149.29.192


Current Path : /usr/lib/python3.6/site-packages/setuptools/__pycache__/
Upload File :
Current File : //usr/lib/python3.6/site-packages/setuptools/__pycache__/ssl_support.cpython-36.pyc

3

9��f,!�"@s�ddlZddlZddlZddlZddlZddlmZmZmZm	Z	ddl
mZmZyddl
Z
Wnek
rtdZ
YnXdddddgZd	j�j�ZyejjZejZWnek
r�eZZYnXe
dk	o�eeefkZydd
l
mZmZWnRek
�r:yddlmZddlmZWnek
�r4dZdZYnXYnXe�sRGd
d�de�Ze�sjddd�Zdd�ZGdd�de�ZGdd�de�Zd dd�Z dd�Z!e!dd��Z"dd�Z#dd�Z$dS)!�N)�urllib�http_client�map�filter)�ResolutionError�ExtractionError�VerifyingHTTPSHandler�find_ca_bundle�is_available�
cert_paths�
opener_fora
/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
/usr/local/share/certs/ca-root-nss.crt
/etc/ssl/ca-bundle.pem
)�CertificateError�match_hostname)r
)rc@seZdZdS)r
N)�__name__�
__module__�__qualname__�rr�!/usr/lib/python3.6/ssl_support.pyr
5sr
�c
Cs�g}|sdS|jd�}|d}|dd�}|jd�}||krLtdt|���|s`|j�|j�kS|dkrt|jd�n>|jd	�s�|jd	�r�|jtj|��n|jtj|�j	d
d��x|D]}|jtj|��q�Wtj
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)
Zdn�hostnameZ
max_wildcardsZpats�partsZleftmostZ	remainderZ	wildcardsZfragZpatrrr�_dnsname_match;s*


r&cCs�|std��g}|jdf�}x0|D](\}}|dkr"t||�r@dS|j|�q"W|s�xF|jdf�D]6}x0|D](\}}|dkrjt||�r�dS|j|�qjWq`Wt|�dkr�td|d	jtt|��f��n*t|�dkr�td
||df��ntd��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 certificateZsubjectAltNameZDNSNZsubjectZ
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!rr)Zcertr$ZdnsnamesZsan�key�value�subrrrros.

rc@s eZdZdZdd�Zdd�ZdS)rz=Simple verifying handler: no auth, subclasses, timeouts, etc.cCs||_tj|�dS)N)�	ca_bundle�HTTPSHandler�__init__)�selfr-rrrr/�szVerifyingHTTPSHandler.__init__cs�j�fdd�|�S)Ncst|�jf|�S)N)�VerifyingHTTPSConnr-)�host�kw)r0rr�<lambda>�sz2VerifyingHTTPSHandler.https_open.<locals>.<lambda>)Zdo_open)r0Zreqr)r0r�
https_open�sz VerifyingHTTPSHandler.https_openN)rrr�__doc__r/r5rrrrr�sc@s eZdZdZdd�Zdd�ZdS)r1z@Simple verifying connection: no auth, subclasses, timeouts, etc.cKstj||f|�||_dS)N)�HTTPSConnectionr/r-)r0r2r-r3rrrr/�szVerifyingHTTPSConn.__init__cCs�tj|j|jft|dd��}t|d�rHt|dd�rH||_|j�|j}n|j}tt	d�rxt	j
|jd�}|j||d�|_nt	j|t	j
|jd�|_yt|jj�|�Wn.tk
r�|jjtj�|jj��YnXdS)NZsource_address�_tunnel�_tunnel_host�create_default_context)Zcafile)Zserver_hostname)Z	cert_reqsZca_certs)�socketZcreate_connectionr2Zport�getattr�hasattr�sockr8r9�sslr:r-Zwrap_socketZ
CERT_REQUIREDrZgetpeercertr
ZshutdownZ	SHUT_RDWR�close)r0r>Zactual_hostZctxrrr�connect�s$

zVerifyingHTTPSConn.connectN)rrrr6r/rArrrrr1�sr1cCstjjt|pt���jS)z@Get a urlopen() replacement that uses ca_bundle for verification)r�requestZbuild_openerrr	�open)r-rrrr�scstj���fdd��}|S)Ncst�d�s�||��_�jS)N�always_returns)r=rD)�args�kwargs)�funcrr�wrapper�s
zonce.<locals>.wrapper)�	functools�wraps)rGrHr)rGr�once�srKcsXyddl}Wntk
r dSXG�fdd�d|j����}|jd�|jd�|jS)Nrcs,eZdZ��fdd�Z��fdd�Z�ZS)z"get_win_certfile.<locals>.CertFilecst�|�j�tj|j�dS)N)�superr/�atexit�registerr@)r0)�CertFile�	__class__rrr/�sz+get_win_certfile.<locals>.CertFile.__init__cs,yt�|�j�Wntk
r&YnXdS)N)rLr@�OSError)r0)rOrPrrr@�sz(get_win_certfile.<locals>.CertFile.close)rrrr/r@�
__classcell__r)rO)rPrrO�srOZCAZROOT)�wincertstore�ImportErrorrOZaddstore�name)rSZ	_wincertsr)rOr�get_win_certfile�s

rVcCs$ttjjt�}t�p"t|d�p"t�S)z*Return an existing CA bundle path, or NoneN)r�os�path�isfilerrV�next�_certifi_where)Zextant_cert_pathsrrrr	�s
c
Cs,ytd�j�Stttfk
r&YnXdS)NZcertifi)�
__import__�whererTrrrrrrr[sr[)r)N)%rWr;rMrrIZsetuptools.extern.six.movesrrrrZ
pkg_resourcesrrr?rT�__all__�striprrrBr.r7�AttributeError�objectr
r
rZbackports.ssl_match_hostnamer'r&rr1rrKrVr	r[rrrr�<module>sP


4)
(
	

?>