a †oe Cã @s²ddlmZddlZddlZddlZddlZddlmZmZddl m Z m Z m Z ddl mZmZmZmZddlmZdd lmZmZdZdZd Zd Zd Zd gZe e e d œZd d„ZeedeƒZ zddl!Z!ddl!m"Z"m#Z#Wne$yìYn0zddl!mZWne$�yYn0zddl%mZWne$�y8Yn0zddl!m&Z&e&Z'WnFe$�y”zddl!m'Z&e&Z'Wne$�yŽdZ'Z&Yn0Yn0zddl!m(Z(Wne$�y¾e&Z(Yn0zddl!m)Z)m*Z*m+Z+Wn e$�yød\Z*Z+dZ)Yn0zddl!m,Z,Wne$�y"dZ,Yn0d -gd¢¡Z.zddl!mZWn$e$�yfGdd„de/ƒZYn0d d!„Z0d"d#„Z1d$d%„Z2d0d&d'„Z3d1d(d)„Z4d*d+„Z5d,d-„Z6d2d.d/„Z7dS)3é)Úabsolute_importN)ÚhexlifyÚ unhexlify)Úmd5Úsha1Úsha256é)ÚInsecurePlatformWarningÚProxySchemeUnsupportedÚSNIMissingWarningÚSSLError)Úsixé)ÚBRACELESS_IPV6_ADDRZ_REÚIPV4_REFzhttp/1.1)é é(é@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ÚleftÚright©rú2C:\Program Files\Certbot\pkgs\urllib3\util\ssl_.pyÚ_const_compare_digest_backportsrZcompare_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)Ú SSLContextc@s8eZdZdd„Zdd„Zd dd„Zdd „Zdd d „ZdS)r,cCs6||_d|_tj|_d|_d|_d|_d|_d|_ dS)NFr) ÚprotocolÚcheck_hostnameÚsslZ CERT_NONEÚ verify_modeÚca_certsÚoptionsÚcertfileÚkeyfileÚciphers)ÚselfZprotocol_versionrrrÚ__init__†szSSLContext.__init__cCs||_||_dS©N)r3r4)r6r3r4rrrÚload_cert_chain‘szSSLContext.load_cert_chainNcCs*||_|durtdƒ‚|dur&tdƒ‚dS)Nz-CA directories not supported in older Pythonsz&CA data not supported in older Pythons)r1r )r6ZcafileZcapathZcadatarrrÚload_verify_locations•s z SSLContext.load_verify_locationscCs ||_dSr8©r5)r6Z 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/1.26.x/advanced-usage.html#ssl-warnings)r4r3r1Ú cert_reqsÚ ssl_versionÚ server_sider5) ÚwarningsÚwarnr r4r3r1r0r-r!r5)r6ZsocketÚserver_hostnamer?Úkwargsrrrr!¡sù úzSSLContext.wrap_socket)NNN)NF)Ú__name__Ú __module__Ú __qualname__r7r9r:r<r!rrrrr,…s   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ÚencodeZdigestÚ_const_compare_digestr)ZcertZ fingerprintZ digest_lengthZhashfuncZfingerprint_bytesZ cert_digestrrrÚassert_fingerprint¶s     ÿÿrOcCs@|dur tSt|tƒr.disable_check_hostnameÚkeylog_filenameZ SSLKEYLOGFILE)r$r&r,r<ÚDEFAULT_CIPHERSr/r r(r)r'r*r2ÚsysÚ version_inforRr[r0ÚhasattrÚosÚenvironrKr_)r>r=r2r5r^Z sslkeylogfilerr\rÚcreate_urllib3_contextús:% ÿþ   rfc  Cs\|} | durt|||d�} |s&| s&| rlz|  || | ¡Wq†ttfyh}zt|ƒ‚WYd}~q†d}~00n|dur†t| dƒr†|  ¡|r¢| dur¢t|ƒr¢tdƒ‚|rÊ| dur¼|  ||¡n|  ||| ¡zt| dƒrà|   t ¡Wnt yôYn0|�ot |ƒ }|�rt �pt�o|}t �s4|�r4t dt¡|�rLt|| | |d�}n t|| | ƒ}|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. Nr;Úload_default_certsz5Client private key is encrypted, password is requiredÚset_alpn_protocolsa€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/1.26.x/advanced-usage.html#ssl-warnings©rB)rfr:ÚIOErrorÚOSErrorr rcrgÚ_is_key_file_encryptedr9rhÚALPN_PROTOCOLSÚNotImplementedErrorÚ is_ipaddressr"ÚIS_SECURETRANSPORTr@rAr Ú_ssl_wrap_socket_impl)Úsockr4r3r=r1rBr>r5Ú ssl_contextZ ca_cert_dirZ key_passwordZ ca_cert_dataÚ tls_in_tlsr]ÚeZuse_sni_hostnameZsend_sniZssl_sockrrrÚssl_wrap_socketcsH&     ÿ ø ÿ rvcCs2tjst|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 ZPY2rPÚbytesÚdecodeÚboolrÚmatchr)ÚhostnamerrrroÉs rocCsRt|dƒ�4}|D]}d|vrWdƒdSqWdƒn1sD0YdS)z*Detects if a key file is encrypted or not.ÚrZ ENCRYPTEDNTF)Úopen)Zkey_fileÚfÚlinerrrrlÖs  2rlcCsF|r&tstdƒ‚t |¡t|||ƒS|r8|j||d�S| |¡SdS)Nz0TLS in TLS requires support for the 'ssl' moduleri)r#r Z$_validate_ssl_context_for_tls_in_tlsr!)rrrsrtrBrrrrqásÿ  rq)NNNN) NNNNNNNNNNNF)N)8Z __future__rZhmacrdrar@ZbinasciirrZhashlibrrrÚ exceptionsr r r r Zpackagesr Úurlrrr,r#r"Z IS_PYOPENSSLrprmrJrrRrNr/r r!Ú ImportErrorZ ssltransportr$r%r&r'r(r)r*Újoinr`ÚobjectrOrVrWrfrvrorlrqrrrrÚs¢          ÿ1ÿ kó f