mf CddlmZddlZddlZddlZddlZddlmZmZddl m Z m Z m Z ddl mZmZmZmZddlmZdd lmZmZdZdZd Zd Zd Zd gZe e e d Zd ZeedeZ ddl!Z!ddl!m"Z"m#Z#n #e$$rYnwxYw ddl!mZn #e$$rYnwxYw ddl%mZn #e$$rYnwxYw ddl!m&Z&e&Z'n$#e$$r ddl!m'Z&e&Z'n#e$$rdxZ'Z&YnwxYwYnwxYw ddl!m(Z(n #e$$re&Z(YnwxYw ddl!m)Z)m*Z*m+Z+n#e$$r d\Z*Z+dZ)YnwxYw ddl!m,Z,n #e$$rdZ,YnwxYwd-gdZ. ddl!mZn#e$$rGdde/ZYnwxYwdZ0d Z1d!Z2 d'd"Z3 d(d#Z4d$Z5d%Z6d)d&Z7dS)*)absolute_importN)hexlify unhexlify)md5sha1sha256)InsecurePlatformWarningProxySchemeUnsupportedSNIMissingWarningSSLError)six)BRACELESS_IPV6_ADDRZ_REIPV4_REFzhttp/1.1) (@ctt|t|z }tt|t|D] \}}|||z z}|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)abresultleftrights H/opt/imunify360/venv/lib64/python3.11/site-packages/urllib3/util/ssl_.py_const_compare_digest_backportr sdQ#a&& ! !F9Q<<166 e$, Q;compare_digest) CERT_REQUIRED wrap_socket)HAS_SNI) SSLTransport) PROTOCOL_TLS)PROTOCOL_SSLv23)PROTOCOL_TLS_CLIENT)OP_NO_COMPRESSION OP_NO_SSLv2 OP_NO_SSLv3)iii) OP_NO_TICKETi@:)z ECDHE+AESGCMzECDHE+CHACHA20z DHE+AESGCMz DHE+CHACHA20z ECDH+AESGCMz DH+AESGCMzECDH+AESzDH+AESz RSA+AESGCMzRSA+AESz!aNULLz!eNULLz!MD5z!DSS) SSLContextc0eZdZdZdZddZdZd dZdS) r/c||_d|_tj|_d|_d|_d|_d|_d|_ dS)NFr) protocolcheck_hostnamessl CERT_NONE verify_modeca_certsoptionscertfilekeyfileciphers)selfprotocol_versions r__init__zSSLContext.__init__sB,DM"'D "}D  DMDL DMDLDLLLr!c"||_||_dSN)r9r:)r<r9r:s rload_cert_chainzSSLContext.load_cert_chains$DM"DLLLr!NcX||_|td|tddS)Nz-CA directories not supported in older Pythonsz&CA data not supported in older Pythons)r7r )r<cafilecapathcadatas rload_verify_locationsz SSLContext.load_verify_locationss;"DM!NOOO!GHHH"!r!c||_dSr@r;)r< cipher_suites r set_cipherszSSLContext.set_cipherss 'DLLLr!Fctjdt|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/1.26.x/advanced-usage.html#ssl-warnings)r:r9r7 cert_reqs ssl_version server_sider;) warningswarnr r:r9r7r6r2r$r;)r<socketserver_hostnamerNkwargss rr$zSSLContext.wrap_socketsj M (    < M M!-#}* FvFFt|FvFF Fr!)NNN)NF)__name__ __module__ __qualname__r>rArFrJr$r!rr/r/ss  # # # I I I I ( ( ( G G G G G Gr!r/c|dd}t|}t|}|s"t d|t|}|| }t||s0t d|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) replacelowerr HASHFUNC_MAPgetr formatrencodedigest_const_compare_digestr)cert fingerprint digest_lengthhashfuncfingerprint_bytes cert_digests rassert_fingerprintrhs%%c2..4466K $$M ..H Q;BB;OOPPP"+"4"4"6"677(4..''))K .? @ @  D K KW[11       r!c|tSt|tr2tt|d}|ttd|z}|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. NCERT_)r# isinstancestrgetattrr4 candidateress rresolve_cert_reqsrqsW)S!!c9d++ ;#w233C r!c|tSt|tr2tt|d}|ttd|z}|S|S)z like resolve_cert_reqs N PROTOCOL_)r'rkrlrmr4rns rresolve_ssl_versionrtsW)S!!c9d++ ;#{Y677C r!cp|r |tkrt}t||pt| t jn|}|*d}|tz}|tz}|tz}|tz}xj |zc_ |t jkstj dkrtdd d_fd}|t jkr|_|n||_t#dr(t$jd}|r|_S) aAll 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 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``, and ``ssl.OP_NO_TICKET``. :param ciphers: Which cipher suites to allow the server to select. :returns: Constructed SSLContext object with specified options :rtype: SSLContext Nr)post_handshake_authTc<tdd d_dSdS)Nr3F)rmr3)contextsrdisable_check_hostnamez6create_urllib3_context..disable_check_hostnameEs/ G-t 4 4 @&+G " " " A @r!keylog_filename SSLKEYLOGFILE)r'r)r/rJDEFAULT_CIPHERSr4r#r+r,r*r-r8sys version_informryr6hasattrosenvironr]r})rMrLr8r;r| sslkeylogfiler{s @rcreate_urllib3_contextrs{J *+55) %%G 2?333&/%6!!II;; $$ < OOwOO S&&&#*:i*G*GW&NN N'+#+++++C%%%'       'w)**4 77  4&3G # Nr!c |} | t|||} |s| s| rA | || | nN#ttf$r}t |d}~wwxYw|$t | dr| |r | t|rt d|r0| | ||n| |||  t | dr| tn#t$rYnwxYw|ot| }|rtpto|}ts|rtjdt"|rt%|| | |}nt%|| | }|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() :param tls_in_tls: Use SSLTransport to wrap the existing socket. NrHload_default_certsz5Client private key is encrypted, password is requiredset_alpn_protocolsaAn 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/1.26.x/advanced-usage.html#ssl-warningsrR)rrFIOErrorOSErrorr rr_is_key_file_encryptedrArALPN_PROTOCOLSNotImplementedError is_ipaddressr%IS_SECURETRANSPORTrOrPr _ssl_wrap_socket_impl)sockr:r9rLr7rRrMr; ssl_context ca_cert_dir key_password ca_cert_data tls_in_tlsr{euse_sni_hostnamesend_snissl_socks rssl_wrap_socketrcsLG)iQQQ%;%,%   ) )(K N N N N!   1++    2F!G!G ""$$$ P<',B7,K,K'NOOOE    # #Hg 6 6 6 6  # #Hg| D D D 70 1 1 7  & &~ 6 6 6      'L|O/L/L+L ,W.    '      D( ':   )w CC Os'6AAA*D DDctjs*t|tr|d}t t j|ptj|S)zDetects 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) rPY2rkbytesdecodeboolrmatchr)hostnames rrrsY 7,z(E22,??7++  h''R+B+H+R+R S SSr!ct|d5}|D]}d|vrddddS dddn #1swxYwYdS)z*Detects if a key file is encrypted or not.r ENCRYPTEDNTF)open)key_fileflines rrrs h    Dd"" #  5s 66::c|r;tstdtj|t|||S|r|||S||S)Nz0TLS in TLS requires support for the 'ssl' moduler)r&r $_validate_ssl_context_for_tls_in_tlsr$)rrrrRs rrrs@ (B  9+FFFD+???-&&t_&MMM&&t,,,r!)NNNN) NNNNNNNNNNNFr@)8 __future__rhmacrrrObinasciirrhashlibrrr exceptionsr r r r packagesrurlrrr/r&r% IS_PYOPENSSLrrr\r rmrar4r#r$ ImportError ssltransportr'r(r)r*r+r,r-joinrobjectrhrqrtrrrrrrWr!rrs&&&&&& ''''''''%%%%%%%%%% 11111111    Tv..     &68VWW JJJ.........   D     D  *******   D  +      "OO++++777777& +++)**,,,+ +'''''''''''&' ???????????   3K        LLL*((&2G0G0G0G.G.G.G.G.GV.G.G.G.G.G0Gf   :.   "=AffffV    ccccL T T T------s' A44A<;A<BBBBB"!B"&B//C5B>=C> C C C  CCCC%$C%) C44 DDDDD3D::EE