← Back
Editing: _sslverify.cpython-38.pyc
U �`�[Z � @ s d dl mZmZ d dlZd dlZd dlmZmZ d dlm Z d dl mZmZ d dl mZ d dlmZmZ d dlmZ d d lmZ d dlmZ G dd � d e�Zejejejejejejej ej!ej"e#edd �iZ$dd� Z%G dd� de&�Z'dd� Z(dd� Z)dd� Z*e*� \Z+Z,d dl-m.Z.m/Z/ d dlm0Z0m1Z1 d dl2m3Z3 d dl4m5Z5 d dl6m7Z7m8Z8 d dl9m:Z:m;Z;m<Z<m=Z= d dlm>Z>m?Z? d d l@mAZA d d!lBmCZCmDZDmEZE d d"lFmGZG d d#lHmIZI d d$l@mJZJ e�K� fd%d&�ZLG d'd(� d(e0�ZMeMjNeMjNA eM_Od)d*� ZPd+d+d,d,d-d-d.d.d/d/d0d0d1d2� ZQG d3d4� d4eR�ZSeSZTeG d5d6� d6��ZUd7d8� ZVG d9d:� d:eU�ZWG d;d<� d<eU�ZXG d=d>� d>eW�ZYeG d?d@� d@��ZZG dAdB� dBeZ�Z[eJe3dCdDd d �dE�e[j\�e[_\eJe3dCdDd d �dE�e[j]�e[_]G dFdG� dGe.�Z^e/e^�G dHdI� dIe_��Z`dJdK� Zae/e^�G dLdM� dMe_��ZbdNdO� ZcdPdQ� Zde/e<�G dRdS� dSe_��ZedfdTdU�Zfe/e=�G dVdW� dWe_��ZgeJe3dCdDd d �dE�egj\�eg_\eJe3dCdDd d �dE�egj]�eg_]e/e;�G dXdY� dYeIe_��ZhdZd[� Zie/e:�G d\d]� d]e_��Zjej�kd^�Zld_ZmG d`da� dae_�ZnG dbdc� dce_�Zoddde� ZpdS )g� )�division�absolute_importN)�Names� NamedConstant)�md5)�SSL�crypto)�lib)�isIPAddress� isIPv6Address)�log)� _oldStyle� )� _idnaBytesc @ s. e Zd ZdZe� Ze� Ze� Ze� Ze� Z dS )� TLSVersionzD TLS versions that we can negotiate with the client/server. N) �__name__� __module__�__qualname__�__doc__r �SSLv3�TLSv1_0�TLSv1_1�TLSv1_2�TLSv1_3� r r �=/usr/lib/python3/dist-packages/twisted/internet/_sslverify.pyr s r Z OP_NO_TLSv1_3c C sR t t�� �}dd� |d|�| �� D �}|rN|�dd� ||�|�d� D �� |S )a� Given a pair of L{TLSVersion} constants, figure out what versions we want to disable (as OpenSSL is an exclusion based API). @param oldest: The oldest L{TLSVersion} we want to allow. @type oldest: L{TLSVersion} constant @param newest: The newest L{TLSVersion} we want to allow, or L{None} for no upper limit. @type newest: L{TLSVersion} constant or L{None} @return: The versions we want to disable. @rtype: L{list} of L{TLSVersion} constants. c S s g | ]}|�qS r r ��.0�xr r r � <listcomp>B s z,_getExcludedTLSProtocols.<locals>.<listcomp>Nc S s g | ]}|�qS r r r r r r r E s )�listr Z iterconstants�index�extend)ZoldestZnewestZversions�excludedVersionsr r r �_getExcludedTLSProtocols2 s "r$ c @ s e Zd ZdZdS )�SimpleVerificationErrorz/ Not a very useful verification error. N)r r r r r r r r r% L s r% c C s2 | � � �� j}||kr.tt|�d t|� ��dS )a� Check only the common name in the certificate presented by the peer and only for an exact match. This is to provide I{something} in the way of hostname verification to users who haven't installed C{service_identity}. This check is overly strict, relies on a deprecated TLS feature (you're supposed to ignore the commonName if the subjectAlternativeName extensions are present, I believe), and lots of valid certificates will fail. @param connection: the OpenSSL connection to verify. @type connection: L{OpenSSL.SSL.Connection} @param hostname: The hostname expected by the user. @type hostname: L{unicode} @raise twisted.internet.ssl.VerificationError: if the common name and hostname don't match. z!=N)Zget_peer_certificate�get_subject� commonNamer% �repr)� connection�hostnamer'