
    $ȂiD              	          S SK r S SKrS SKrS SKrS SKrS SKJrJrJrJrJ	r	J
r
JrJrJr  S SKJr  SSKJr  \R$                  " 5       S    r\" \" \\R/                  S5      5      5      r\S:  a  \" S\S     S\S    35      eS	\S
\S\4S jr\" SS5      r\" SS5      r\r\
r\r \r!\r"\r#\r$\r%\r&\r'\" \&5      r(\r)\	r*\" \%5      r+\" \!5      r,\" \"5      r-\" \#5      r.\" \$5      r/\r0\r1\" \5      r2\" \5      r3\" \5      r4\r5\r6 \)\,/\Rn                  l8        \2\Rn                  l9        \2/\Rt                  l8        \,\Rt                  l9        \*\/\Rv                  l8        \-\Rv                  l9        \4\./\Rx                  l8        \*\Rx                  l9        \4\/\Rz                  l8        \*\Rz                  l9        \1/\R|                  l8        \3\R|                  l9        \\-/\R~                  l8        \3\R~                  l9        \(\(\" \45      /\R                  l8        \*\R                  l9        \4\" \55      /\R                  l8        \*\R                  l9        \4\l4        \5\l5        \*\l*        SrBSrC\(/\R                  l8        S\R                  l9        \(/\R                  l8        \'\R                  l9        \)\\ /\R                  l8        \-\R                  l9        \-\ /\R                  l8        \\R                  l9        \-\\\ /\R                  l8        \\R                  l9        \)\\/\R                  l8        \,\R                  l9        \,/\R                  l8        \\R                  l9        \,/\R                  l8        \\R                  l9        \)\" \(5      \\0/\R                  l8        \.\R                  l9        \)\\0/\R                  l8        \/\R                  l9        \/\/\R                  l8        S\R                  l9        \./\R                  l8        \\R                  l9        \.\/\R                  l8        \\R                  l9        \+/\R                  l8        \\R                  l9        \+/\R                  l8        \-\R                  l9        \)R                  \S5      \lT        \R                  " \S5      \lU        \(\l(        \.\l.        \-\l-        \+\l+        S\*S\R                  S\R                  S\R                  4S jrX\X\R                  lY        \X\Rx                  lY        \X\Rz                  lY        \X\R                  lY         " S S5      rZS\[S\,4S jr\S\[S\"4S jr]S\-S\S-  4S  jr^S!\_\[   S\/4S" jr`\ R                  S#\R                  S\R                  S   4S$ j5       rd S)S%\R                  S&\_\[   S'\S-  SS4S( jjreg! \V a
    \" S5      Sef = f)*    N)	CDLLPOINTERc_boolc_char_pc_int32c_longc_uint32c_ulongc_void_p)find_library   )_set_ssl_context_verify_mode.)
      z,Only OS X 10.8 and newer are supported, not namemacos10_16_pathreturnc                      [         S:  a  UnO[        U 5      nU(       d  [        e[        USS9$ ! [         a    [	        SU  S35      Sef = f)z:Loads a CDLL by name, falling back to known path on 10.16+)r      T)	use_errnozThe library z failed to loadN)_mac_version_infor   OSErrorr   ImportError)r   r   paths      ND:\sksbv-state-backend\venv\Lib\site-packages\pip/_vendor/truststore/_macos.py
_load_cdllr      s]    J ("D%DMDD)) JLo>?TIJs	   .1 ASecurityz6/System/Library/Frameworks/Security.framework/SecurityCoreFoundationzB/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation   r   kCFAllocatorDefaultkCFTypeArrayCallBackszError initializing ctypesresult_argsc                 ~   [        U 5      S:X  a  U$ Sn [        R                  U S5      n[        R                  " U[        R
                  " [        R                  5      5      n[        R                  U[        R                  5      nUcZ  [        R                  " S5      n[        R                  UUS[        R                  5      n U (       d  [        S5      eUR                  nUb  [        R                  U5        Ub  US:X  a  SU  3n[         R"                  " U5      e! Ub  [        R                  U5        f f = f)z4
Raises an error if the OSStatus value is non-zero.
r   N   'Error copying C string from CFStringRef z8SecureTransport operation returned a non-zero OSStatus: )intr   SecCopyErrorMessageStringctypescastr   r   r   CFStringGetCStringPtrCFConstkCFStringEncodingUTF8create_string_bufferCFStringGetCStringr   value	CFReleasesslSSLError)r#   r$   r%   error_message_cfstringerror_message_cfstring_c_void_pmessagebuffers          r   _handle_osstatusr;      s%    6{a "!=!)!C!CFD!Q +1++"FNN6??$C+
' !66+W-J-J
 ?006F#66/--	F GHHllG "-$$%;< 'R-LVHU
,,w
 "-$$%;< .s   CD! !D<c                   8    \ rS rSrSr\" S5      rSrSrSr	Sr
Srg	)
r/   i  zCoreFoundation constantsi  iiii N)__name__
__module____qualname____firstlineno____doc__CFStringEncodingr0   #errSecIncompleteCertRevocationCheckerrSecHostNameMismatcherrSecCertificateExpirederrSecNotTrusted__static_attributes__r=       r   r/   r/     s(    ",Z8*0'#%rI   r/   r3   c                 ^    [         R                  [         R                  U [        U 5      5      $ N)r   CFDataCreater!   len)r3   s    r   _bytes_to_cf_data_refrN     s&    &&**E3u: rI   c                     [         R                  " U 5      n[        R                  [        R                  U[
        R                  5      nU$ )z]
Given a Python binary data, create a CFString.
The string must be CFReleased by the caller.
)r,   r   r   CFStringCreateWithCStringr!   r/   r0   )r3   c_strcf_strs      r   _bytes_to_cf_stringrS     s>    
 OOE"E55**%%F
 MrI   cf_string_refc                 .   [         R                  U [        R                  5      nUcY  [        R
                  " S5      n[         R                  XS[        R                  5      nU(       d  [        S5      eUR                  nUb  UR                  S5      nU$ )z
Creates a Unicode string from a CFString object. Used entirely for error
reporting.
Yes, it annoys me quite a lot that this function is this complex.
r'   r(   zutf-8)
r   r.   r/   r0   r,   r1   r2   r   r3   decode)rT   stringr:   r#   s       r   _cf_string_ref_to_strrX   &  s     11w44F ~,,T2224)F)F
 CDDw'MrI   certsc                 L   [         R                  [         R                  S[        R                  " [         R
                  5      5      nU(       d  [        S5      eU  H  nSnSn [        U5      n[        R                  [         R                  U5      n[         R                  X5        U(       a  [         R                  U5        U(       a  [         R                  U5        M  M     U$ ! U(       a  [         R                  U5        U(       a  [         R                  U5        f f = f)zBuilds a CFArray of SecCertificateRefs from a list of DER-encoded certificates.
Responsibility of the caller to call CoreFoundation.CFRelease on the CFArray.
r   zUnable to allocate memory!N)r   CFArrayCreateMutabler!   r,   byrefr"   MemoryErrorrN   r   SecCertificateCreateWithDataCFArrayAppendValuer4   )rY   cf_array	cert_datacf_datasec_cert_refs        r   _der_certs_to_cf_cert_arrayrd   =  s     22**	^99:H
 677	
	7+I6G#@@22GL --hE((1((6   O ((1((6 s   $AC((;D#ctxc              #      #    U R                   nU R                  nSU l         [        U [        R                  5         S v   Xl         [        X5        g ! Xl         [        X5        f = f7f)NF)check_hostnameverify_moder   r5   	CERT_NONE)re   rg   rh   s      r   _configure_contextrj   [  sV     ''N//KC cmm47+$S6 ,$S6s   :A)A A)A&&A)ssl_context
cert_chainserver_hostnamec                 	   S nS nS nS n UbP  S n [        UR                  S5      5      n[        R                  SU5      nU(       a  [        R                  U5        O[        R                  SS 5      nUnU R                  [        R                  -  (       a  [        R                  [        R                  S[        R                  " [        R                  5      5      n[        R                  XH5        [        R                  U5        [        R                  [         ["        -  5      n	[        R                  XI5        [        R                  U	5        O-U R                  [        R$                  -  (       a  ['        S5      eS n [)        U5      n[        R+                  5       n[        R-                  X4[        R                  " U5      5        U(       a  [        R                  U5        U R/                  SS9n
U
(       a?  S n [)        U
5      n[        R1                  X[5        U(       a  [        R                  U5        [        R3                  US5        [        R5                  5       n[        R7                  U[        R                  " U5      5      nUS:X  a  SnO#US:X  a  SnO[        R8                  " SU< 35      eSnU(       d  [        R;                  U5      nU R<                  [        R>                  :w  a+  U[@        RB                  :X  d  U[@        RD                  :X  a  SnO'U RF                  (       d  U[@        RH                  :X  a  SnU(       d  S n [        RK                  U5      n[M        U5      =(       d    S	n[        RO                  5       n[        RQ                  U[        R                  " U5      5        [        RR                  " U5      nUUl*        UUl+        Ue U(       a  [        R                  U5        U(       a  [        R                  U5        g g ! U(       a  [        R                  U5        f f = f! U(       a  [        R                  U5        f f = f! U(       a  [        R                  U5        f f = f! U(       a  [        R                  U5        f f = f! U(       a  [        R                  U5        U(       a  [        R                  U5        f f = f)
NasciiTr   z/VERIFY_CRL_CHECK_LEAF not implemented for macOS)binary_formFr   z8Unknown result from Security.SecTrustEvaluateWithError: zCertificate verification failed),rS   encoder   SecPolicyCreateSSLr   r4   verify_flagsr5   VERIFY_CRL_CHECK_CHAINr[   r!   r,   r\   r"   r_   SecPolicyCreateRevocation#kSecRevocationUseAnyAvailableMethod%kSecRevocationRequirePositiveResponseVERIFY_CRL_CHECK_LEAFNotImplementedErrorrd   SecTrustRefSecTrustCreateWithCertificatesget_ca_certsSecTrustSetAnchorCertificates!SecTrustSetAnchorCertificatesOnly
CFErrorRefSecTrustEvaluateWithErrorr6   CFErrorGetCoderh   CERT_REQUIREDr/   rG   rF   rg   rE   CFErrorCopyDescriptionrX   SecTrustResultTypeSecTrustGetTrustResultSSLCertVerificationErrorverify_messageverify_code)rk   rl   rm   rY   policiestrustcf_errorcf_str_hostname
ssl_policyrevocation_policyctx_ca_certs_derctx_ca_certssec_trust_eval_result
is_trustedcf_error_codecf_error_string_refcf_error_messagesec_trust_result_typeerrs                      r   _verify_peercerts_implr   h  s   
 EHEHB,&"O>"5o6L6LW6U"V%88O
"",,_=!44T4@J##c&@&@@%::22^AABH
 --hC$$Z0 ( B B378! --hJ$$%67%%(A(AA%&WXX	0/
;E ((*E33e!4 ((/ 0;/G/G 0H 0
 L;:;KL66uK",,\: 	225%@!,,. ( B B6<<)!

 !A%J"a'J,,JK`Jcd  *99(CM
 &&#*;*;;!9!99 G$D$DD!
..!W%C%CC!
 "&B&4&K&KH&U# **=> 98 ! )1(C(C(E%//6<<(=> 223CD%5""/	+ 6 $$X.$$U+ u #",,_= #L ((/   ",,\:  @ '",,-@A ' $$X.$$U+ sh   R% 0P  ER% A	P? 4R%  Q! !D3R% BR P<<R% ?QR% !R  R% R""R% %;S rK   )f
contextlibr,   platformr5   typingr   r   r   r   r   r   r	   r
   r   ctypes.utilr   _ssl_constantsr   mac_ver_mac_versiontuplemapr*   splitr   r   strr   r   r   BooleanCFIndexrC   CFDataCFStringCFArrayCFMutableArrayCFErrorCFTypeCFTypeID	CFTypeRefCFAllocatorRefOSStatusr   	CFDataRefCFStringRef
CFArrayRefCFMutableArrayRefCFArrayCallBacksCFOptionFlagsSecCertificateRefSecPolicyRefrz   r   SecTrustOptionFlagsr^   argtypesrestypeSecCertificateCopyDatar+   r}   r~   ru   rr   r{   r   rv   rw   r4   CFGetTypeIDrP   r.   r2   rL   CFDataGetLengthCFDataGetBytePtrCFArrayCreater[   r_   CFArrayGetCountCFArrayGetValueAtIndexr   r   in_dllr!   r"   AttributeErrorAnyr;   errcheckr/   bytesrN   rS   rX   listrd   contextmanager
SSLContextIteratorrj   r   r=   rI   r   <module>r      s      
 
 
 
 % 8!!$#c<#5#5c#:;< w

67H7K6LAN_`aNbMcd 
JS J3 J4 J" H H
 
 	

	FO	W
FO	hW
N+  H% x h  v=6Di5PH))24EH))10A/BH##,.7H##+3;X2FH&&/1<H&&.7BJ6OH**35=H**2;F:PH..79AH..63@/H&&/1=H&&.,3[+AH(*6H' 	8H++4
 7?H++3 	"#0H##, /7H##+&H"4H H*+',-))2N%'+N$+4+N')1N& 	9N,,5
 8CN,,45@BR4SN((13;N((0 		2N%%. 17N%%-,:Hg+NN(*3N'/8kN""+-4N""*09{N##,.6N##+ 			-N  ) ,6N  ( 	4N''0
 3DN''/2CX1NN%%.04N%%-/9lN""+-4N""*6@'5JN))24<N))1.8\N!!*,3N!!)6@\N))24?N))1)7)>)>-*N& ,4??/,N(  )N *N!,N *N2 X 2 &** 2 FJJ 2 6:: 2 j 4D ' ' 02B & & /6F * * 3+;   (  9 u   t .tE{ 7H < 	7CNN 	7vt/D 	7 	7 #'K,K,UK, 4ZK, 
	K,A  =
1
2<=s   	OW W!