zmc
2023-08-08 e792e9a60d958b93aef96050644f369feb25d61b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
U
I=®d»8ã@s(ddlmZddlZddlZddlZddlZddlmZmZddl    m
Z
m Z m Z ddl mZmZddlmZmZmZdd    lmZdZd
Zd
Zd
Ze
e e d œZd d „ZeedeƒZz(ddlZddlmZm Z ddlmZWne!k
rìYnXzddlm"Z"e"Z#WnJe!k
rLzddlm#Z"e"Z#Wne!k
rFdZ#Z"YnXYnXzddlm$Z$m%Z%m&Z&Wn"e!k
rˆd\Z$Z%dZ&YnXd 'dddddddddd d!d"d#d$g¡Z(zdd%lmZWn&e!k
ræGd&d'„d'e)ƒZYnXd(d)„Z*d*d+„Z+d,d-„Z,d6d.d/„Z-d7d0d1„Z.d2d3„Z/d4d5„Z0dS)8é)Úabsolute_importN)ÚhexlifyÚ    unhexlify)Úmd5Úsha1Úsha256é)ÚIPV4_REÚBRACELESS_IPV6_ADDRZ_REé)ÚSSLErrorÚInsecurePlatformWarningÚSNIMissingWarning)ÚsixF)é é(é@cCsDtt|ƒt|ƒƒ}tt|ƒt|ƒƒD]\}}|||AO}q&|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)ÚabsÚlenÚzipÚ    bytearray)ÚaÚbÚresultÚlÚr©rúTD:\z\workplace\VsCode\pyvenv\venv\Lib\site-packages\pip/_vendor/urllib3/util/ssl_.pyÚ_const_compare_digest_backportsrÚcompare_digest)Ú wrap_socketÚ CERT_REQUIRED)ÚHAS_SNI)Ú PROTOCOL_TLS)ÚPROTOCOL_SSLv23)Ú OP_NO_SSLv2Ú OP_NO_SSLv3ÚOP_NO_COMPRESSION)iiiú:z ECDHE+AESGCMzECDHE+CHACHA20z
DHE+AESGCMz DHE+CHACHA20z ECDH+AESGCMz    DH+AESGCMzECDH+AESzDH+AESz
RSA+AESGCMzRSA+AESz!aNULLz!eNULLz!MD5z!DSS)Ú
SSLContextc@s8eZdZdd„Zdd„Zd dd„Zdd    „Zdd d „ZdS)r)cCs6||_d|_tj|_d|_d|_d|_d|_d|_    dS)NFr)
ÚprotocolÚcheck_hostnameÚsslÚ    CERT_NONEÚ verify_modeÚca_certsÚoptionsÚcertfileÚkeyfileÚciphers)ÚselfZprotocol_versionrrrÚ__init__kszSSLContext.__init__cCs||_||_dS©N)r1r2)r4r1r2rrrÚload_cert_chainvszSSLContext.load_cert_chainNcCs*||_|dk    rtdƒ‚|dk    r&tdƒ‚dS)Nz-CA directories not supported in older Pythonsz&CA data not supported in older Pythons)r/r )r4ÚcafileÚcapathÚcadatarrrÚload_verify_locationszs
z SSLContext.load_verify_locationscCs
||_dSr6©r3)r4Z cipher_suiterrrÚ set_ciphersƒszSSLContext.set_ciphersFcCs>t dt¡|j|j|j|j|j|dœ}t|fd|j    i|—ŽS)Na2A 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)r2r1r/Ú    cert_reqsÚ ssl_versionÚ server_sider3)
ÚwarningsÚwarnr r2r1r/r.r*r r3)r4ÚsocketÚserver_hostnamer@Úkwargsrrrr †sù
úzSSLContext.wrap_socket)NNN)NF)Ú__name__Ú
__module__Ú __qualname__r5r7r;r=r rrrrr)js
 
    r)cCsn| dd¡ ¡}t|ƒ}t |¡}|s4td |¡ƒ‚t| ¡ƒ}||ƒ     ¡}t
||ƒsjtd |t |ƒ¡ƒ‚dS)zá
    Checks if given fingerprint matches the supplied certificate.
 
    :param cert:
        Certificate as bytes object.
    :param fingerprint:
        Fingerprint as string of hexdigits, can be interspersed by colons.
    r(Úz"Fingerprint of invalid length: {0}z6Fingerprints did not match. Expected "{0}", got "{1}".N) ÚreplaceÚlowerrÚ HASHFUNC_MAPÚgetr ÚformatrÚencodeÚdigestÚ_const_compare_digestr)ÚcertÚ fingerprintÚ digest_lengthÚhashfuncÚfingerprint_bytesÚ cert_digestrrrÚassert_fingerprint›s
 
 
ÿÿrXcCs@|dkr tSt|tƒr<tt|dƒ}|dkr8ttd|ƒ}|S|S)aë
    Resolves the argument to a numeric constant, which can be passed to
    the wrap_socket function/method from the ssl module.
    Defaults to :data:`ssl.CERT_REQUIRED`.
    If given a string it is assumed to be the name of the constant in the
    :mod:`ssl` module or its abbreviation.
    (So you can specify `REQUIRED` instead of `CERT_REQUIRED`.
    If it's neither `None` nor a string we assume it is already the numeric
    constant which can directly be passed to wrap_socket.
    NÚCERT_)r!Ú
isinstanceÚstrÚgetattrr,©Ú    candidateÚresrrrÚresolve_cert_reqs¸s 
 r`cCs@|dkr tSt|tƒr<tt|dƒ}|dkr8ttd|ƒ}|S|S)z 
    like resolve_cert_reqs
    NÚ    PROTOCOL_)r#rZr[r\r,r]rrrÚresolve_ssl_versionÏs
 rbcCs¨t|ptƒ}| |pt¡|dkr(tjn|}|dkrPd}|tO}|tO}|tO}|j    |O_    |tjksrt
j dkrˆt |ddƒdk    rˆd|_ ||_t |ddƒdk    r¤d|_|S)a÷All arguments have the same meaning as ``ssl_wrap_socket``.
 
    By default, this function does a lot of the same work that
    ``ssl.create_default_context`` does on Python 3.4+. It:
 
    - Disables SSLv2, SSLv3, and compression
    - Sets a restricted set of server ciphers
 
    If you wish to enable SSLv3, you can do::
 
        from pip._vendor.urllib3.util import ssl_
        context = ssl_.create_urllib3_context()
        context.options &= ~ssl_.OP_NO_SSLv3
 
    You can do the same to enable compression (substituting ``COMPRESSION``
    for ``SSLv3`` in the last line above).
 
    :param ssl_version:
        The desired protocol version to use. This will default to
        PROTOCOL_SSLv23 which will negotiate the highest protocol that both
        the server and your installation of OpenSSL support.
    :param cert_reqs:
        Whether to require the certificate verification. This defaults to
        ``ssl.CERT_REQUIRED``.
    :param options:
        Specific OpenSSL options. These default to ``ssl.OP_NO_SSLv2``,
        ``ssl.OP_NO_SSLv3``, ``ssl.OP_NO_COMPRESSION``.
    :param ciphers:
        Which cipher suites to allow the server to select.
    :returns:
        Constructed SSLContext object with specified options
    :rtype: SSLContext
    Nr)éééÚpost_handshake_authTr+F)r)r#r=ÚDEFAULT_CIPHERSr,r!r%r&r'r0ÚsysÚ version_infor\rfr.r+)r?r>r0r3ÚcontextrrrÚcreate_urllib3_contextßs,$ ÿþÿrkc 
CsH|} | dkrt|||d} |s&|    s&| rœz|  ||    | ¡Wq¶tk
rb} z t| ƒ‚W5d} ~ XYq¶tk
r˜} z| jtjkr†t| ƒ‚‚W5d} ~ XYq¶Xn|dkr¶t| dƒr¶|  ¡|rÒ|
dkrÒt    |ƒrÒtdƒ‚|rú|
dkrì|  
||¡n|  
|||
¡|dk    rt |ƒrt r>t r2|dk    r2| j||dSt dt¡|  |¡S)aÈ
    All arguments except for server_hostname, ssl_context, and ca_cert_dir have
    the same meaning as they do when using :func:`ssl.wrap_socket`.
 
    :param server_hostname:
        When SNI is supported, the expected hostname of the certificate
    :param ssl_context:
        A pre-made :class:`SSLContext` object. If none is provided, one will
        be created using :func:`create_urllib3_context`.
    :param ciphers:
        A string of ciphers we wish the client to support.
    :param ca_cert_dir:
        A directory containing CA certificates in multiple separate files, as
        supported by OpenSSL's -CApath flag or the capath argument to
        SSLContext.load_verify_locations().
    :param key_password:
        Optional password if the keyfile is encrypted.
    :param ca_cert_data:
        Optional string containing CA certificates in PEM format suitable for
        passing as the cadata parameter to SSLContext.load_verify_locations()
    Nr<Úload_default_certsz5Client private key is encrypted, password is required)rDa€An HTTPS request has been made, but the SNI (Server Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. 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)rkr;ÚIOErrorr ÚOSErrorÚerrnoÚENOENTÚhasattrrlÚ_is_key_file_encryptedr7Ú is_ipaddressÚIS_SECURETRANSPORTr"r rArBr)Úsockr2r1r>r/rDr?r3Ú ssl_contextÚ ca_cert_dirÚ key_passwordÚ ca_cert_datarjÚerrrÚssl_wrap_socket+sB#  ÿÿþø r{cCs2tjst|tƒr| d¡}tt |¡p.t |¡ƒS)zæDetects whether the hostname given is an IPv4 or IPv6 address.
    Also detects IPv6 addresses with Zone IDs.
 
    :param str hostname: Hostname to examine.
    :return: True if the hostname is an IP address, False otherwise.
    Úascii)    rÚPY2rZÚbytesÚdecodeÚboolr    Úmatchr
)Úhostnamerrrrs‰s
rsc    Cs<t|dƒ(}|D]}d|krW5QR£dSqW5QRXdS)z*Detects if a key file is encrypted or not.rÚ    ENCRYPTEDTF)Úopen)Úkey_fileÚfÚlinerrrrr–s
 rr)NNNN) NNNNNNNNNNN)1Ú
__future__rrorAÚhmacrhÚbinasciirrÚhashlibrrrÚurlr    r
Ú
exceptionsr r rÚpackagesrr)r"Ú IS_PYOPENSSLrtrLrr\rQr,r r!Ú ImportErrorr#r$r%r&r'ÚjoinrgÚobjectrXr`rbrkr{rsrrrrrrÚ<module>sž      
òÿ1ÿ
Nô
^