File: //opt/cppython/lib/python3.8/site-packages/setuptools/__pycache__/ssl_support.cpython-38.pyc
U
<D�gu! � @ s� d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dl m
Z
mZ zd dlZW n e
k
rl dZY nX dddddgZd�� �� ZzejjZejjZW n ek
r� e ZZY nX edk o�eeefkZzd d lmZmZ W nR e
k
�r4 zd d
lmZ d dlmZ W n e
k
�r. dZdZY nX Y nX e�sLG dd
� d
e�Ze�sdddd�Zdd� ZG dd� de�ZG dd� de�Zddd�Z dd� Z!e!dd� �Z"dd� Z#dd� Z$dS ) � N)�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 )r
c @ s e Zd ZdS )r N)�__name__�
__module__�__qualname__� r r �C/opt/cppython/lib/python3.8/site-packages/setuptools/ssl_support.pyr 7 s r � c
C s� g }| sdS | � d�}|d }|dd� }|�d�}||krLtdt| � ��|s`| �� |�� kS |dkrt|�d� n>|�d �s�|�d �r�|�t�|�� n|�t�|�� d
d�� |D ]}|�t�|�� q�t�
dd
�|� d tj�} | �
|�S )zqMatching according to RFC 6125, section 6.4.3
https://tools.ietf.org/html/rfc6125#section-6.4.3
F�.r r N�*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�patr r r �_dnsname_match= s,
�r* c C s� | st d��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 certificate�subjectAltNamer �DNSN�subject�
commonNamer z&hostname %r doesn't match either of %sz, zhostname %r doesn't match %rr z=no appropriate commonName or subjectAltName fields were found) �
ValueError�getr* r �lenr r �mapr )�certr! �dnsnames�san�key�value�subr r r r
s s>