Current File : //lib/python3.9/site-packages/setuptools/__pycache__/ssl_support.cpython-39.opt-1.pyc |
a
��khu! � @ s� d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dl m
Z
mZ zd dlZW n e
yj dZY n0 g d�Zd�� �� ZzejjZejjZW n ey� e ZZY n0 eduo�eeefvZzd dlmZmZ W nN e
�y& zd dlmZ d dlmZ W n e
�y dZdZY n0 Y n0 e�s>G dd � d e�Ze�sVddd�Zd
d� 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 �:/usr/lib/python3.9/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)
Zdn�hostnameZ
max_wildcardsZpats�partsZleftmostZ remainderZ 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 certificateZsubjectAltNamer ZDNSNZsubjectZ
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 )Zcertr ZdnsnamesZsan�key�value�subr r r r
s s>