3 Pf/ ! @ s d dl mZ d dlZd dlZd dlZd dlmZmZ d dlm Z m Z mZ ddlm Z mZmZ dZdZdZdZe e edZd d ZeedeZy,d dlZd dlmZmZmZ d d lmZ W n ek r Y nX yd dlmZmZmZ W n" ek r d0\ZZdZY nX dj dddddddddddddd d!d"gZ!yd d#lmZ W n. ek rr d dl"Z"G d$d% d%e#ZY nX d&d' Z$d(d) Z%d*d+ Z&d1d,d-Z'd2d.d/Z(dS )3 )absolute_importN)hexlify unhexlify)md5sha1sha256 )SSLErrorInsecurePlatformWarningSNIMissingWarningF) ( @ c C sH t t| t| }x*tt| t|D ]\}}|||A O }q(W |dkS )z Compare two digests of equal length in constant time. The digests must be of type str/bytes. Returns True if the digests match, and False otherwise. r )abslenzip bytearray)abresultlr r /usr/lib/python3.6/ssl_.py_const_compare_digest_backport s r Zcompare_digest)wrap_socket CERT_NONEPROTOCOL_SSLv23)HAS_SNI)OP_NO_SSLv2OP_NO_SSLv3OP_NO_COMPRESSION i :zTLS13-AES-256-GCM-SHA384zTLS13-CHACHA20-POLY1305-SHA256zTLS13-AES-128-GCM-SHA256zECDH+AESGCMz ECDH+CHACHA20z DH+AESGCMzDH+CHACHA20zECDH+AES256z DH+AES256zECDH+AES128zDH+AESz RSA+AESGCMzRSA+AESz!aNULLz!eNULLz!MD5) SSLContextc @ s\ e Zd Zdej kodk n p*dejkZdd Zdd Zdd d Zdd Z dddZ dS )r% r c C s6 || _ d| _tj| _d | _d| _d | _d | _d | _ d S )NFr ) protocolcheck_hostnamesslr verify_modeca_certsoptionscertfilekeyfileciphers)selfZprotocol_versionr r r __init__c s zSSLContext.__init__c C s || _ || _d S )N)r. r/ )r1 r. r/ r r r load_cert_chainn s zSSLContext.load_cert_chainNc C s || _ |d k rtdd S )Nz-CA directories not supported in older Pythons)r, r )r1 ZcafileZcapathr r r load_verify_locationsr s z SSLContext.load_verify_locationsc C s | j std|| _d S )NzYour version of Python does not support setting a custom cipher suite. Please upgrade to Python 2.7, 3.2, or later if you need this functionality.)supports_set_ciphers TypeErrorr0 )r1 Zcipher_suiter r r set_ciphersx s zSSLContext.set_ciphersFc C sT t jdt | j| j| j| j| j|d}| jrDt |fd| j i|S t |f|S d S )Na2 A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings)r/ r. r, cert_reqsssl_versionserver_sider0 )warningswarnr r/ r. r, r+ r( r5 r r0 )r1 Zsocketserver_hostnamer: kwargsr r r r s zSSLContext.wrap_socket)r r&