
    hM                       % S r SSKJr  SSKrSSKJr   SSKJr  SSKrSSKrSSKrSSKJr  SS	KJr  SS
KJr  SSKJr  \R*                  (       a  SSKJr  SS/r\R2                  R4                  \R6                  R8                  \R2                  R:                  \R6                  R8                  \R<                  \R6                  R>                  0r S\!S'   \"" \S5      (       a;  \"" \R6                  S5      (       a#  \R6                  RF                  \ \RH                  '   \"" \S5      (       a;  \"" \R6                  S5      (       a#  \R6                  RJ                  \ \RL                  '   \RN                  \R6                  RP                  \RR                  \R6                  RT                  \RV                  \R6                  RT                  \R6                  RX                  -   0r-\-R]                  5        V Vs0 s H  u  pX_M	     snn r/\0" \R6                  SS5      \0" \R6                  SS5      -  r1S\!S'   \0" \R6                  SS5      r2S\!S'   \0" \R6                  SS5      r3S\!S'   \0" \R6                  SS5      r4S\!S'   \0" \R6                  S S5      r5S\!S!'   \Rl                  Rn                  \1\Rl                  Rp                  \1\Rl                  Rr                  \1\2-  \Rl                  Rt                  \1\2-  \3-  \Rl                  Rv                  \1\2-  \3-  \4-  \Rl                  Rx                  \1\2-  \3-  \4-  0r=S\!S"'   \Rl                  Rn                  \1\2-  \3-  \4-  \5-  \Rl                  Rp                  \1\3-  \4-  \5-  \Rl                  Rr                  \1\4-  \5-  \Rl                  Rt                  \1\5-  \Rl                  Rv                  \1\Rl                  Rx                  \10r>S\!S#'   S$r?\R2                  R                  rA\R                  " \C5      rDS/S% jrES/S& jrFS/S' jrGS0S( jrHS1S) jrI " S* S+5      rJ\R                  \JlK         " S, S-5      rL            S2S. jrMg! \	 a     " S S\
5      r GNYf = fs  snn f )3a  
Module for using pyOpenSSL as a TLS backend. This module was relevant before
the standard library ``ssl`` module supported SNI, but now that we've dropped
support for Python 2.7 all relevant Python versions support SNI so
**this module is no longer recommended**.

This needs the following packages installed:

* `pyOpenSSL`_ (tested with 16.0.0)
* `cryptography`_ (minimum 1.3.4, from pyopenssl)
* `idna`_ (minimum 2.0)

However, pyOpenSSL depends on cryptography, so while we use all three directly here we
end up having relatively few packages required.

You can install them with the following command:

.. code-block:: bash

    $ python -m pip install pyopenssl cryptography idna

To activate certificate checking, call
:func:`~urllib3.contrib.pyopenssl.inject_into_urllib3` from your Python code
before you begin making HTTP requests. This can be done in a ``sitecustomize``
module, or at any other time before your application begins using ``urllib3``,
like this:

.. code-block:: python

    try:
        import urllib3.contrib.pyopenssl
        urllib3.contrib.pyopenssl.inject_into_urllib3()
    except ImportError:
        pass

.. _pyopenssl: https://www.pyopenssl.org
.. _cryptography: https://cryptography.io
.. _idna: https://github.com/kjd/idna
    )annotationsN)x509)UnsupportedExtensionc                      \ rS rSrSrg)r   2    N)__name__
__module____qualname____firstlineno____static_attributes__r       K/var/www/html/env/lib/python3.13/site-packages/urllib3/contrib/pyopenssl.pyr   r   2   s    r   r   )BytesIO)socket)timeout   )utilX509inject_into_urllib3extract_from_urllib3zdict[int, int]_openssl_versionsPROTOCOL_TLSv1_1TLSv1_1_METHODPROTOCOL_TLSv1_2TLSv1_2_METHODOP_NO_SSLv2OP_NO_SSLv3int_OP_NO_SSLv2_OR_SSLv3OP_NO_TLSv1_OP_NO_TLSv1OP_NO_TLSv1_1_OP_NO_TLSv1_1OP_NO_TLSv1_2_OP_NO_TLSv1_2OP_NO_TLSv1_3_OP_NO_TLSv1_3_openssl_to_ssl_minimum_version_openssl_to_ssl_maximum_versioni @  c                     [        5         [        [        l        [        [        R                  l        S[        l        S[        R                  l        g)z7Monkey-patch urllib3 with PyOpenSSL-backed SSL-support.TN)_validate_dependencies_metPyOpenSSLContextr   
SSLContextssl_IS_PYOPENSSLr   r   r   r   r      s1      &DO+DIID!DIIr   c                     [         [        l        [         [        R                  l        S[        l        S[        R                  l        g)z4Undo monkey-patching by :func:`inject_into_urllib3`.FN)orig_util_SSLContextr   r/   r0   r1   r   r   r   r   r      s+     +DO/DIID"DIIr   c                     SSK Jn   [        U SS5      c  [        S5      eSSKJn  U" 5       n[        USS5      c  [        S5      eg)	zo
Verifies that PyOpenSSL's package-level dependencies have been met.
Throws `ImportError` if they are not met.
r   )
Extensionsget_extension_for_classNzX'cryptography' module missing required functionality.  Try upgrading to v1.3.4 or newer.r   _x509zS'pyOpenSSL' module missing required functionality. Try upgrading to v0.14 or newer.)cryptography.x509.extensionsr5   getattrImportErrorOpenSSL.cryptor   )r5   r   r   s      r   r-   r-      s[     8z4d;C0
 	
 $6DtWd#+/
 	
 ,r   c                V    SS jnSU ;   a  U $ U" U 5      nUc  gUR                  S5      $ )a  
Converts a dNSName SubjectAlternativeName field to the form used by the
standard library on the given Python version.

Cryptography produces a dNSName as a unicode string that was idna-decoded
from ASCII bytes. We need to idna-encode that string to get it back, and
then on Python 3 we also need to convert to unicode via UTF-8 (the stdlib
uses PyUnicode_FromStringAndSize on it, which decodes via UTF-8).

If the name cannot be idna-encoded then we return None signalling that
the name given should be skipped.
c                   SSK n S HL  nU R                  U5      (       d  M  U [        U5      S n UR                  S5      UR                  U 5      -   s  $    UR                  U 5      $ ! UR                  R
                   a     gf = f)z
Borrowed wholesale from the Python Cryptography Project. It turns out
that we can't just safely call `idna.encode`: it can explode for
wildcard names. This avoids that problem.
r   N)z*..ascii)idna
startswithlenencodecore	IDNAError)namer@   prefixs      r   idna_encode'_dnsname_to_stdlib.<locals>.idna_encode   s     		%??6**F.D!==1DKK4EEE & ;;t$$yy"" 		s   A) 2A) A) )BB:Nutf-8)rF   strreturnbytes | None)decode)rF   rH   encoded_names      r   _dnsname_to_stdlibrQ      s9    $ d{t$Lw''r   c                ^   U R                  5       n UR                  R                  [        R                  5      R
                  n[        [        UR                  [        R                   5      5       Vs/ s H  nUc  M  SU4PM     nnUR#                  S UR                  [        R$                  5       5       5        U$ ! [        R                   a    / s $ [        R                  [        [        R                  [        4 a"  n[        R                  SU5        / s SnA$ SnAff = fs  snf )zM
Given an PyOpenSSL certificate, provides all the subject alternative names.
zA problem was encountered with the certificate that prevented urllib3 from finding the SubjectAlternativeName field. This can affect certificate validation. The error was %sNDNSc              3  <   #    U  H  nS [        U5      4v   M     g7f)z
IP AddressN)rL   ).0rF   s     r   	<genexpr>$get_subj_alt_name.<locals>.<genexpr>  s      .Uds4y!.Us   )to_cryptography
extensionsr6   r   SubjectAlternativeNamevalueExtensionNotFoundDuplicateExtensionr   UnsupportedGeneralNameTypeUnicodeErrorlogwarningmaprQ   get_values_for_typeDNSNameextend	IPAddress)	peer_certcertexterF   namess         r   get_subj_alt_namerl      s    $$&Doo55d6Q6QRXX: *C,C,CDLL,QRRD 	R 
 
 
LL .1.E.Ednn.U  LG !! 	''	  	> 		
 	.s/   3C  4D*?D* D'-D'D"D'"D'c                      \ rS rSrSr S       SS jjrSS jrSS jrSS jrSS jr	SS jr
SS	 jrSS
 jrSS jrSS jrSS jr S   SS jjrSS jrS S jrSrg)!WrappedSocketi  z@API-compatibility wrapper for Python OpenSSL's Connection-class.c                D    Xl         X l        X0l        SU l        SU l        g Nr   F)
connectionr   suppress_ragged_eofs_io_refs_closed)selfrq   r   rr   s       r   __init__WrappedSocket.__init__  s"     %$8!r   c                6    U R                   R                  5       $ N)r   filenoru   s    r   rz   WrappedSocket.fileno!  s    {{!!##r   c                    U R                   S:  a  U =R                   S-  sl         U R                  (       a  U R                  5         g g )Nr      )rs   rt   closer{   s    r   _decref_socketiosWrappedSocket._decref_socketios%  s1    ==1MMQM<<JJL r   c                F    U R                   R                  " U0 UD6nU$ ! [        R                  R                   aN  nU R
                  (       a  UR                  S:X  a   S nAg[        UR                  S   [        U5      5      UeS nAf[        R                  R                   a:    U R                   R                  5       [        R                  R                  :X  a   ge [        R                  R                   af  n[        R                  " U R                  U R                  R!                  5       5      (       d  [#        S5      UeU R                  " U0 UD6s S nA$ S nAf[        R                  R$                   a   n[&        R(                  " SU< 35      UeS nAff = f)NzUnexpected EOFr   r   The read operation timed outread error: )rq   recvOpenSSLSSLSysCallErrorrr   argsOSErrorrL   ZeroReturnErrorget_shutdownRECEIVED_SHUTDOWNWantReadErrorr   wait_for_readr   
gettimeoutr   ErrorsslSSLError)ru   r   kwargsdatarj   s        r   r   WrappedSocket.recv+  s3   	??''88D* K) {{'' 	8((QVV7M-MaffQiQ0a7{{** 	++-1N1NN{{(( 	2%%dkk4;;3I3I3KLL<=1Dyy$1&11 {{   	<,,aU34!;	<s@     F !B$#BAF  F >AEF !F  FF c                B    U R                   R                  " U0 UD6$ ! [        R                  R                   aN  nU R
                  (       a  UR                  S:X  a   S nAg[        UR                  S   [        U5      5      UeS nAf[        R                  R                   a:    U R                   R                  5       [        R                  R                  :X  a   ge [        R                  R                   af  n[        R                  " U R                  U R                  R!                  5       5      (       d  [#        S5      UeU R                  " U0 UD6s S nA$ S nAf[        R                  R$                   a   n[&        R(                  " SU< 35      UeS nAff = f)Nr   r   r   r   )rq   	recv_intor   r   r   rr   r   r   rL   r   r   r   r   r   r   r   r   r   r   r   r   )ru   r   r   rj   s       r   r   WrappedSocket.recv_intoD  s+   	<??,,d=f=={{'' 	8((QVV7M-MaffQiQ0a7{{** 	++-1N1NN{{(( 	7%%dkk4;;3I3I3KLL<=1D~~t6v66 {{   	<,,aU34!;	<s@    F!B"#BAFF<AEF!F>FFc                8    U R                   R                  U5      $ ry   )r   
settimeout)ru   r   s     r   r   WrappedSocket.settimeout[  s    {{%%g..r   c                     U R                   R                  U5      $ ! [        R                  R                   aT  n[
        R                  " U R                  U R                  R                  5       5      (       d  [        5       Ue S nAM  S nAf[        R                  R                   a(  n[        UR                  S   [        U5      5      UeS nAff = fNr   )rq   sendr   r   WantWriteErrorr   wait_for_writer   r   r   r   r   r   rL   )ru   r   rj   s      r   _send_until_doneWrappedSocket._send_until_done^  s    8++D11;;-- **4;;8N8N8PQQ!)*;;++ 8affQiQ0a78s!    CA	B!C,#CCc                    SnU[        U5      :  a0  U R                  XU[        -    5      nX#-  nU[        U5      :  a  M/  g g r   )rB   r   SSL_WRITE_BLOCKSIZE)ru   r   
total_sentsents       r   sendallWrappedSocket.sendalli  sI    
3t9$((*/B"BCD J	 3t9$r   c                     U R                   R                  5         g ! [        R                  R                   a   n[
        R                  " SU< 35      UeS nAff = f)Nzshutdown error: )rq   shutdownr   r   r   r   r   )ru   howrj   s      r   r   WrappedSocket.shutdownq  sM    	@OO$$&{{   	@,,!1!78a?	@s    AAAc                T    SU l         U R                  S::  a  U R                  5         g g )NTr   )rt   rs   _real_closer{   s    r   r   WrappedSocket.closew  s&    ==A r   c                     U R                   R                  5       $ ! [        R                  R                   a     g f = fry   )rq   r   r   r   r   r{   s    r   r   WrappedSocket._real_close|  s6    	??((**{{   		s    ==c                   U R                   R                  5       nU(       d  U$ U(       a8  [        R                  R	                  [        R                  R
                  U5      $ SUR                  " 5       R                  444[        U5      S.$ )N
commonName)subjectsubjectAltName)	rq   get_peer_certificater   cryptodump_certificateFILETYPE_ASN1get_subjectCNrl   )ru   binary_formr   s      r   getpeercertWrappedSocket.getpeercert  st     335K>>227>>3O3OQUVV '(8(8(:(=(=>@B/5
 	
r   c                6    U R                   R                  5       $ ry   )rq   get_protocol_version_namer{   s    r   versionWrappedSocket.version  s    88::r   c                h    U R                   R                  5       nU(       a  UR                  5       $ S $ ry   )rq   get_alpn_proto_negotiatedrO   )ru   
alpn_protos     r   selected_alpn_protocol$WrappedSocket.selected_alpn_protocol  s*    __>>@
&0z  ":d:r   )rt   rs   rq   r   rr   N)T)rq   OpenSSL.SSL.Connectionr   
socket_clsrr   boolrM   NonerM   r    rM   r   )r   
typing.Anyr   r   rM   bytes)r   r   r   r   rM   r    )r   floatrM   r   )r   r   rM   r    )r   r   rM   r   )r   r    rM   r   )F)r   r   rM   z"dict[str, list[typing.Any]] | None)rM   rL   )rM   
str | None)r	   r
   r   r   __doc__rv   rz   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rn   rn     s    J &*	
*
 
 #	

 

$2<./	8@
 #(

	+
 ;;r   rn   c                     \ rS rSrSrSS jr\SS j5       r\R                  SS j5       r\SS j5       r	\	R                  SS j5       r	\SS j5       r
\
R                  SS	 j5       r
SS
 jrSS jr   S       SS jjr  S       S S jjrS!S jr    S"           S#S jjrSS jr\SS j5       r\R                  S$S j5       r\SS j5       r\R                  S%S j5       rSrg)&r.   i  z
I am a wrapper class for the PyOpenSSL ``Context`` object. I am responsible
for translating the interface of the standard library ``SSLContext`` object
to calls into PyOpenSSL.
c                >   [         U   U l        [        R                  R	                  U R                  5      U l        SU l        SU l        [        R                  R                  U l        [        R                  R                  U l        [        R                  U l        g rp   )r   protocolr   r   Context_ctx_optionscheck_hostnamer   
TLSVersionMINIMUM_SUPPORTED_minimum_versionMAXIMUM_SUPPORTED_maximum_versionVERIFY_X509_TRUSTED_FIRST_verify_flags)ru   r   s     r   rv   PyOpenSSLContext.__init__  si    )(3KK''6	#%(^^%E%E%(^^%E%E"%"?"?r   c                    U R                   $ ry   )r   r{   s    r   optionsPyOpenSSLContext.options  s    }}r   c                0    Xl         U R                  5         g ry   )r   _set_ctx_optionsru   r[   s     r   r   r     s    r   c                    U R                   $ ry   )r   r{   s    r   verify_flagsPyOpenSSLContext.verify_flags  s    !!!r   c                v    Xl         U R                  R                  5       R                  U R                   5        g ry   )r   r   get_cert_store	set_flagsr   s     r   r   r     s)    "		  ",,T-?-?@r   c                D    [         U R                  R                  5          $ ry   )_openssl_to_stdlib_verifyr   get_verify_moder{   s    r   verify_modePyOpenSSLContext.verify_mode  s    ()B)B)DEEr   c                R    U R                   R                  [        U   [        5        g ry   )r   
set_verify_stdlib_to_openssl_verify_verify_callbackr   s     r   r   r     s    		6u=?OPr   c                8    U R                   R                  5         g ry   )r   set_default_verify_pathsr{   s    r   r   )PyOpenSSLContext.set_default_verify_paths  s    		**,r   c                    [        U[        5      (       a  UR                  S5      nU R                  R	                  U5        g )NrK   )
isinstancerL   rC   r   set_cipher_list)ru   cipherss     r   set_ciphersPyOpenSSLContext.set_ciphers  s/    gs##nnW-G		!!'*r   Nc                ^   Ub  UR                  S5      nUb  UR                  S5      n U R                  R                  X5        Ub%  U R                  R                  [        U5      5        g g ! [        R
                  R                   a   n[        R                  " SU< 35      UeS nAff = f)NrK   z%unable to load trusted certificates: )	rC   r   load_verify_locationsr   r   r   r   r   r   )ru   cafilecapathcadatarj   s        r   r  &PyOpenSSLContext.load_verify_locations  s     ]]7+F]]7+F	UII++F;!		//@ "{{   	U,,!FqeLMSTT	Us   AA. .B,B''B,c                  ^  U R                   R                  U5        TbE  [        T[        5      (       d  TR	                  S5      mU R                   R                  U4S j5        U R                   R                  U=(       d    U5        g ! [        R                  R                   a   n[        R                  " SU< 35      UeS nAff = f)NrK   c                    > T$ ry   r   )_passwords    r   <lambda>2PyOpenSSLContext.load_cert_chain.<locals>.<lambda>  s    8r   z"Unable to load certificate chain: )r   use_certificate_chain_filer   r   rC   set_passwd_cbuse_privatekey_filer   r   r   r   r   )ru   certfilekeyfiler  rj   s      ` r   load_cert_chain PyOpenSSLContext.load_cert_chain  s    	RII00:#!(E22'w7H		''(;<II))'*=X>{{   	R,,!CA5IJPQQ	Rs   BB C	)CC	c                    U Vs/ s H#  n[         R                   R                  US5      PM%     nnU R                  R                  U5      $ s  snf )Nr?   )r   to_bytesr   set_alpn_protos)ru   	protocolsps      r   set_alpn_protocols#PyOpenSSLContext.set_alpn_protocols  sB    =FGYTYY''73Y	Gyy((33 Hs   *Ac                   [         R                  R                  U R                  U5      nU(       a[  [        R
                  R                  U5      (       d7  [        U[        5      (       a  UR                  S5      nUR                  U5        UR                  5           UR                  5          [)        Xa5      $ ! [         R                  R                   a@  n[        R                  " XR                  5       5      (       d  [!        S5      Ue S nAMw  S nAf[         R                  R"                   a   n[$        R&                  " SU< 35      UeS nAff = f)NrK   zselect timed outzbad handshake: )r   r   
Connectionr   r   r0   is_ipaddressr   rL   rC   set_tlsext_host_nameset_connect_statedo_handshaker   r   r   r   r   r   r   rn   )ru   sockserver_sidedo_handshake_on_connectrr   server_hostnamecnxrj   s           r   wrap_socketPyOpenSSLContext.wrap_socket  s    kk$$TYY5 499#9#9/#J#J/3//"1"8"8"A$$_5C  " S'' ;;,, ))$0ABB!"451<;;$$ Cll_QE#:;BCs$   B; ;E5D!E5EEc                    U R                   R                  U R                  [        U R                     -  [
        U R                     -  5        g ry   )r   set_optionsr   r*   r   r+   r   r{   s    r   r   !PyOpenSSLContext._set_ctx_options  sC    		MM-d.C.CDE-d.C.CDE	
r   c                    U R                   $ ry   )r   r{   s    r   minimum_version PyOpenSSLContext.minimum_version      $$$r   c                0    Xl         U R                  5         g ry   )r   r   )ru   r.  s     r   r.  r/         /r   c                    U R                   $ ry   )r   r{   s    r   maximum_version PyOpenSSLContext.maximum_version#  r0  r   c                0    Xl         U R                  5         g ry   )r   r   )ru   r4  s     r   r4  r5  '  r2  r   )r   r   r   r   r   r   r   )r   r    rM   r   r   )r[   r    rM   r   )r[   zssl.VerifyModerM   r   r   )r   zbytes | strrM   r   )NNN)r  r   r  r   r  rN   rM   r   )NN)r  rL   r  r   r  r   rM   r   )r  zlist[bytes | str]rM   r   )FTTN)r#  r   r$  r   r%  r   rr   r   r&  zbytes | str | NonerM   rn   )r.  r    rM   r   )r4  r    rM   r   )r	   r
   r   r   r   rv   propertyr   setterr   r   r   r  r  r  r  r(  r   r.  r4  r   r   r   r   r.   r.     s   @   ^^    " " A A F F Q Q-+ "!#	UU U 	U
 
U( ##	RR R 	R
 
R 4 "(,%).2(( ( "&	(
 #( ,( 
(>
 % %     % %    r   r.   c                    US:H  $ r   r   )r'  r   err_no	err_depthreturn_codes        r   r   r   -  s     Q;r   r   )rF   rL   rM   r   )rg   r   rM   zlist[tuple[str, str]])r'  r   r   r   r:  r    r;  r    r<  r    rM   r   )Nr   
__future__r   OpenSSL.SSLr   cryptographyr   cryptography.x509r   r:   	Exceptionloggingr   typingior   r   r   r    r   TYPE_CHECKINGr;   r   __all__r0   PROTOCOL_TLSr   SSLv23_METHODPROTOCOL_TLS_CLIENTPROTOCOL_TLSv1TLSv1_METHODr   __annotations__hasattrr   r   r   r   	CERT_NONEVERIFY_NONECERT_OPTIONALVERIFY_PEERCERT_REQUIREDVERIFY_FAIL_IF_NO_PEER_CERTr   itemsr   r9   r!   r#   r%   r'   r)   r   r   TLSv1TLSv1_1TLSv1_2TLSv1_3r   r*   r+   r   r/   r3   	getLoggerr	   r`   r   r   r-   rQ   rl   rn   makefiler.   r   )kvs   00r   <module>r^     sQ  &P #  6  
   '  	# !"8
9 	IIGKK55II!!7;;#<#<00% >  3"##=M(N(N.5kk.H.Hc**+
3"##=M(N(N.5kk.H.Hc**+ MM7;;**w{{..w{{..kk--.  /H.M.M.OP.OdaQT.OP  %W[[-CgKKG  s  GKK:c :gkk?A> >gkk?A> >gkk?A> > NN$$&;NN/NN1L@NN1L@>QNN,~=NNN$$,~=N3   NN$$
	
	 	 		 NN.?.PNN1NB^SNN1NBNN1NN$$&;3  $  yy++  !"#
4&(R-`E; E;P $,, M  M `	
  	
  
{  y R Qs   Q  3Q8 Q54Q5