
    i                        d dl mZ d dlZd dlZd dlZd dlZd dlZd dlZd dlm	Z	 d dl
mZ ej        rd dlZ	 	 dddZdZdS )    )annotationsN)sha256)UnsupportedOperationctxssl.SSLContextcertdatastr | byteskeydatastr | bytes | Nonepassword5typing.Callable[[], str | bytes] | str | bytes | NonereturnNonec                ^   t           j        dk    r^t           j                            d          du r=t           j                            d          du rt          dt           j                   t	          t          j        d                                                     d}t          |t                    r|
                    d          }|*t          |t                    r|
                    d          }t          t          d
          r!t          j        |t          j                  }n)ddlm}m}m}m}	m}
m} |                    d          p|                    d          }|st          d          |                    |          }|j        } |	|                                          }	  || |t          j        t          j        z             |t8          j        t8          j        z                      }n$# t>          $ r}t          d|           d	}~ww xY w|dk    r,t          dt          j          |
                                 d| }d| }t          j!        "                    |          du rWt          j!        "                    |          r|}n5t          j#        |          $                                 t          d          t          j%        |t8          j        t8          j        z             tM          |d          5 }|'                    |           |r|'                    |           |j(        }d	d	d	           n# 1 swxY w Y   | )                    ||           t          j#        |          $                                 t          j!        "                    |          rt          j*        |           t          j!        "                    |          st          j!        "                    |          rtW          j,        dtZ                     d	S d	S )z
    Unique workaround the known limitation of CPython inability to initialize the mTLS context without files.
    Only supported on Linux, FreeBSD, and OpenBSD.
    :raise UnsupportedOperation: If anything goes wrong in the process.
    linuxfreebsdFopenbsdzQUnable to provide support for in-memory client certificate: Unsupported platform     z.pemasciiNmemfd_creater   )c_intc_ushortcdllcreate_string_buffer	get_errnoutilrtczTUnable to provide support for in-memory client certificate: libc or librt not found.z<Unable to provide support for in-memory client certificate: z/proc/self/fd/z	/dev/shm/zWUnable to provide support for in-memory client certificate: no virtual patch available?w)r   zcIn-memory client certificate: The kernel leaked a file descriptor outside of its expected lifetime.).sysplatform
startswithr   r   secretstoken_bytes	hexdigest
isinstancebytesdecodehasattrosr   MFD_CLOEXECctypesr   r   r   r   r   r   find_libraryLoadLibraryshm_openencodeO_RDWRO_CREATstatS_IRUSRS_IWUSRSystemErrorstrerrorpathexistsfdopenclosechmodopenwritenameload_cert_chainunlinkwarningswarnResourceWarning)r   r   r
   r   unique_namefdr   r   r   r   r   r   loclib	_shm_openbuf_nameer9   shm_pathfps                       [/root/projects/butler/venv/lib/python3.11/site-packages/urllib3_future/contrib/imcc/_shm.pyrA   rA      sd    	L##I..%77L##I..%77"n`c`lnn
 
 	
 !!4R!8!899CCEEKKKK(E"" ,??7++gu%% 	.nnW--Gr>"" "_[".99 	XWWWWWWWWWWWWWWW%%?):):3)?)? 	&f   s##L	 ('(:(:(<(<==		bi"*,--455 BB
  	 	 	&RqRR  	
 88&ir{[d[d[f[fOgOgii  
 !B  D );((H	w~~du$$7>>(## 	DDIbMM!!!&i   HT4<$,.///	dC B
 	HHWw               x000 IbMM	w~~h 
	(	w~~d 
rw~~h77 
q	
 	
 	
 	
 	

 
s+   6AH 
H%H  H%4MMM)rA   )NN)
r   r   r   r	   r
   r   r   r   r   r   )
__future__r   r+   r$   r4   r!   typingrC   hashlibr   ior   TYPE_CHECKINGsslrA   __all__     rO   <module>rY      s    " " " " " " 				   



         # # # # # #	 JJJ #'FJ	g
 g
 g
 g
 g
T rX   