Your IP : 3.23.103.14


Current Path : /lib/python3.8/site-packages/setuptools/__pycache__/
Upload File :
Current File : //lib/python3.8/site-packages/setuptools/__pycache__/ssl_support.cpython-38.pyc

U

�Qab-!�@s�ddlZddlZddlZddlZddlZddlmZmZmZm	Z	ddl
mZmZzddl
Z
Wnek
rtdZ
YnXdddddgZd	����ZzejjZejZWnek
r�eZZYnXe
dk	o�eeefkZzdd
l
mZmZWnRek
�r:zddlmZdd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.8/site-packages/setuptools/ssl_support.pyr
5sr
�c
Cs�g}|sdS|�d�}|d}|dd�}|�d�}||krLtdt|���|s`|��|��kS|dkrt|�d�n>|�d	�s�|�d	�r�|�t�|��n|�t�|��	d
d��|D]}|�t�|��q�t�
dd
�|�dtj�}	|	�
|�S)zqMatching according to RFC 6125, section 6.4.3

        https://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}|�dd�}|D]*\}}|dkr t||�r@dS|�|�q |s�|�dd�D]6}|D],\}}|dkrdt||�r�dS|�|�qdq\t|�dkr�td	|d
�tt|��f��n*t|�dkr�td||df��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 certificateZsubjectAltNamerZDNSNZsubjectZ
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�subrrrros2

�
�rc@s eZdZdZdd�Zdd�ZdS)rz=Simple verifying handler: no auth, subclasses, timeouts, etc.cCs||_t�|�dS�N)�	ca_bundle�HTTPSHandler�__init__)�selfr.rrrr0�szVerifyingHTTPSHandler.__init__cs���fdd�|�S)Ncst|�jf|�Sr-)�VerifyingHTTPSConnr.)�host�kw�r1rr�<lambda>��z2VerifyingHTTPSHandler.https_open.<locals>.<lambda>)Zdo_open)r1Zreqrr5r�
https_open�s
�z VerifyingHTTPSHandler.https_openN)rrr�__doc__r0r8rrrrr�sc@s eZdZdZdd�Zdd�ZdS)r2z@Simple verifying connection: no auth, subclasses, timeouts, etc.cKstj||f|�||_dSr-)�HTTPSConnectionr0r.)r1r3r.r4rrrr0�szVerifyingHTTPSConn.__init__cCs�t�|j|jft|dd��}t|d�rHt|dd�rH||_|��|j}n|j}tt	d�rxt	j
|jd�}|j||d�|_nt	j|t	j
|jd�|_zt|j��|�Wn.tk
r�|j�tj�|j���YnXdS)NZsource_address�_tunnel�_tunnel_host�create_default_context)Zcafile)Zserver_hostname)Z	cert_reqsZca_certs)�socketZcreate_connectionr3Zport�getattr�hasattr�sockr;r<�sslr=r.Zwrap_socketZ
CERT_REQUIREDrZgetpeercertr
ZshutdownZ	SHUT_RDWR�close)r1rAZactual_hostZctxrrr�connect�s.

�
�
zVerifyingHTTPSConn.connectN)rrrr9r0rDrrrrr2�sr2cCstj�t|pt���jS)z@Get a urlopen() replacement that uses ca_bundle for verification)r�requestZbuild_openerrr	�open)r.rrrr�s�cst����fdd��}|S)Ncst�d�s�||��_�jS)N�always_returns)r@rG)�args�kwargs��funcrr�wrapper�s
zonce.<locals>.wrapper)�	functools�wraps)rKrLrrJr�once�srOcsZzddl}Wntk
r"YdSXG�fdd�d|j����}|�d�|�d�|jS)Nrcs,eZdZ��fdd�Z��fdd�Z�ZS)z"get_win_certfile.<locals>.CertFilecst�|���t�|j�dSr-)�superr0�atexit�registerrCr5��CertFile�	__class__rrr0�sz+get_win_certfile.<locals>.CertFile.__init__cs,zt�|���Wntk
r&YnXdSr-)rPrC�OSErrorr5rSrrrC�sz(get_win_certfile.<locals>.CertFile.close)rrrr0rC�
__classcell__r�rT)rUrrT�srTZCAZROOT)�wincertstore�ImportErrorrTZaddstore�name)rYZ	_wincertsrrXr�get_win_certfile�s

r\cCs$ttjjt�}t�p"t|d�p"t�S)z*Return an existing CA bundle path, or NoneN)r�os�path�isfilerr\�next�_certifi_where)Zextant_cert_pathsrrrr	�s��c
Cs.ztd���WStttfk
r(YnXdS)NZcertifi)�
__import__�whererZrrrrrrrasra)r)N)%r]r>rQrrMZsetuptools.extern.six.movesrrrrZ
pkg_resourcesrrrBrZ�__all__�striprrrEr/r:�AttributeError�objectr
r
rZbackports.ssl_match_hostnamer'r&rr2rrOr\r	rarrrr�<module>sZ
�

4)
(
	


?>