관리-도구
편집 파일: ssl.cpython-37.opt-2.pyc
B YI~d�� � @ s� d dl Z d dlZd dlmZ d dlmZmZm Z d dlZd dlmZm Z mZ d dlmZmZmZ d dlmZmZmZmZmZmZmZ d dlmZmZ d dlmZmZmZm Z yd d lm!Z! W n e"k r� Y nX d d lm#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z, d dlm-Z-m.Z. ej/de0d d� ed� e j/de0dd� ed� ej/de0dd� ed� ej/de0dd� ed� e j/de0dd� ed� ej/de0dd� ed� e1j2 Z3e1_3dd� e1j4�5� D �Z6e7e1dd�Z8G dd� de�Z9e j:dk�r�d d lm;Z;m<Z< d d!l=m=Z=m>Z>m?Z?m@Z@ d d"l=mAZAmBZB d dl=ZCd dlDZDd dlEZEd dlFZFeGZHd#gZIeJed$�ZKe-ZLeZMd%d&� ZNd'd(� ZOd)d*� ZPd+d,� ZQed-d.�ZRd/d0� ZSG d1d2� d2ed2d3��ZTG d4d5� d5eTe�ZUG d6d7� d7e�ZVeUjWfdddd8�d9d:�ZXe2feYd;eUjWdddddd<�d=d>�ZZeXZ[eZZ\G d?d@� d@�Z]dAdB� Z^G dCdD� dDe=�Z_e_eV_`e]eV_addd;eYe2ddEdEdf dFdG�ZbdHdI� ZcdJZddKZedLdM� ZfdNdO� Zge2dfdPdQ�ZhdRdS� ZidS )T� N)� namedtuple)�Enum�IntEnum�IntFlag)�OPENSSL_VERSION_NUMBER�OPENSSL_VERSION_INFO�OPENSSL_VERSION)�_SSLContext� MemoryBIO� SSLSession)�SSLError�SSLZeroReturnError�SSLWantReadError�SSLWantWriteError�SSLSyscallError�SSLEOFError�SSLCertVerificationError)�txt2obj�nid2obj)�RAND_status�RAND_add� RAND_bytes�RAND_pseudo_bytes)�RAND_egd) �HAS_SNI�HAS_ECDH�HAS_NPN�HAS_ALPN� HAS_SSLv2� HAS_SSLv3� HAS_TLSv1�HAS_TLSv1_1�HAS_TLSv1_2�HAS_TLSv1_3)�_DEFAULT_CIPHERS�_OPENSSL_API_VERSION� _SSLMethodc C s | � d�o| dkS )NZ PROTOCOL_�PROTOCOL_SSLv23)� startswith)�name� r* �(/opt/alt/python37/lib64/python3.7/ssl.py�<lambda>| � r, )�source�Optionsc C s | � d�S )NZOP_)r( )r) r* r* r+ r, � r- ZAlertDescriptionc C s | � d�S )NZALERT_DESCRIPTION_)r( )r) r* r* r+ r, � r- ZSSLErrorNumberc C s | � d�S )NZ SSL_ERROR_)r( )r) r* r* r+ r, � r- �VerifyFlagsc C s | � d�S )NZVERIFY_)r( )r) r* r* r+ r, � r- � VerifyModec C s | � d�S )NZCERT_)r( )r) r* r* r+ r, � r- c C s i | ]\}}||�qS r* r* )�.0r) �valuer* r* r+ � <dictcomp>� s r4 ZPROTOCOL_SSLv2c @ s6 e Zd ZejZejZejZ ej ZejZ ejZejZdS )� TLSVersionN)�__name__� __module__�__qualname__�_sslZPROTO_MINIMUM_SUPPORTEDZMINIMUM_SUPPORTEDZPROTO_SSLv3�SSLv3ZPROTO_TLSv1ZTLSv1Z PROTO_TLSv1_1ZTLSv1_1Z PROTO_TLSv1_2ZTLSv1_2Z PROTO_TLSv1_3ZTLSv1_3ZPROTO_MAXIMUM_SUPPORTEDZMAXIMUM_SUPPORTEDr* r* r* r+ r5 � s r5 �win32)�enum_certificates� enum_crls)�socket�AF_INET�SOCK_STREAM�create_connection)� SOL_SOCKET�SO_TYPEz tls-unique�HOSTFLAG_NEVER_CHECK_SUBJECTc C s� | sdS | � d�}|s&| �� |�� kS |dkr<td�| ���| �d�\}}}d|krbtd�| ���|sttd�| ���|dkr�td�| ���|�d�\}}}|r�|s�dS |�� |�� kS ) NF�*� z1too many wildcards in certificate DNS name: {!r}.�.z9wildcard can only be present in the leftmost label: {!r}.z>sole wildcard without additional labels are not support: {!r}.z<partial wildcards in leftmost label are not supported: {!r}.)�count�lower�CertificateError�format� partition)Zdn�hostnameZ wildcardsZdn_leftmost�sepZdn_remainderZhostname_leftmostZhostname_remainderr* r* r+ �_dnsname_match� s2 rO c C s� yt �| �}W n tk r" Y n"X t �|�| kr6|S td�| ���yt �t j| �S tk rt td�| ���Y n tk r� Y nX td�| ���d S )Nz'{!r} is not a quad-dotted IPv4 address.z+{!r} is neither an IPv4 nor an IP6 address.z{!r} is not an IPv4 address.) �_socketZ inet_aton�OSErrorZ inet_ntoa� ValueErrorrK Z inet_ptonZAF_INET6�AttributeError)Zipname�addrr* r* r+ �_inet_paton� s rU c C s t | �� �}||kS )N)rU �rstrip)Zcert_ipaddress�host_ipZipr* r* r+ �_ipaddress_match s rX c C sN | st d��yt|�}W n t k r0 d }Y nX g }| �dd�}xb|D ]Z\}}|dkrz|d krnt||�rnd S |�|� qH|dkrH|d k r�t||�r�d S |�|� qHW |s�xF| �dd�D ]6}x0|D ](\}}|dkr�t||�r�d S |�|� q�W q�W t|�dk�rtd |d �t t |��f ��n,t|�dk�rBtd||d f ��ntd ��d S )Nztempty or no certificate, match_hostname needs a SSL socket or SSL context with either CERT_OPTIONAL or CERT_REQUIREDZsubjectAltNamer* ZDNSz IP AddressZsubjectZ commonNamerF z&hostname %r doesn't match either of %sz, zhostname %r doesn't match %rr z=no appropriate commonName or subjectAltName fields were found)rR rU �getrO �appendrX �lenrJ �join�map�repr)�certrM rW ZdnsnamesZsan�keyr3 �subr* r* r+ �match_hostname s>