https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/mercurial/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/mercurial/__pycache__/sslutil.cpython-310.pyc
o

^�Ub%��@s\ddlmZddlZddlZddlZddlZddlZddlmZddl	m
Z
ddlmZddl
mZmZm	Z	mZddlmZmZmZhd	�Ze
ed
d�Ze�Ze
ede�ed
��r^e�d�e
ede�ed��rme�d�e
ede�ed��r|e�d�dd�Zdd�Zd)dd�Z	d*dd�ZGdd�de�Z d+dd �Z!d!d"�Z"d#d$�Z#d%d&�Z$d'd(�Z%dS),�)�absolute_importN�)�_)�getattr)�hex)�encoding�error�pycompat�util)�hashutil�resourceutil�
stringutil>�tls1.0�tls1.1�tls1.2�HAS_SNIF�	HAS_TLSv1�PROTOCOL_TLSv1r�HAS_TLSv1_1�PROTOCOL_TLSv1_1r�HAS_TLSv1_2�PROTOCOL_TLSv1_2rc
	Cs�t�|�}dgddddddd�}dd�}tdhsJ�d}d	}|�d
||�}|||�d|}|�d
||�}|||�|�d
d�}|�d
d
||�}|jrSd}|sSd}||d	<||d<|�d
d|�}	|	D]/}
|
�d�s{tjt	d�||
ft	d�d��|
�
dd�\}}
|
�dd���}
|d�
||
f�qe|�d|�D]}
|
�dd���}
|d�
d|
f�d|d<q�|dr�tj|d<d|d<n|jr�d|d<tj|d<d|d<|�dd�r�d|d<|�d
d |�}|dr�|r�|�t	d!�|�|ddu�rj|�rt�|�}tj�|��st�t	d"�d#|f|f��||d$<n<|�d%d&�}|�r@t�|�}tj�|��s?t�t	d'�|t	d(�d)��n|d�rSt|�}|�rS|�d*|�||d$<|�s_|d�retj|d<ntj|d<|ddu�ssJ�|S)+zhObtain security settings for a hostname.

    Returns a dict of settings relevant to that hostname.
    TNF)�allowloaddefaultcerts�certfingerprints�cafile�disablecertverification�legacyfingerprint�minimumprotocol�
verifymode�cipherscSs8|tvrtjtd�||ftd�d�tt��d��dS)Ns-unsupported protocol from hostsecurity.%s: %ssvalid protocols: %s� ��hint)�configprotocolsr�Abortr�join�sorted)�protocol�key�r)�3/usr/lib/python3/dist-packages/mercurial/sslutil.py�validateprotocol[s����z'_hostsettings.<locals>.validateprotocolrrr�hostsecuritys%s:minimumprotocolrs
%s:cipherssDEFAULTs%s:fingerprints)ssha1:ssha256:ssha512:sinvalid fingerprint for %s: %ss0must begin with "sha1:", "sha256:", or "sha512:"r!�:r�rshostfingerprints�sha1rrrr�develsdisableloaddefaultcertss%s:verifycertsfiless(hostsecurity.%s:verifycertsfile ignored when host fingerprints defined; using host fingerprints for verification)
s'path specified by %s does not exist: %sshostsecurity.%s:verifycertsfilerswebscacertsscould not find web.cacerts: %ss  (try installing the %s package)sca-certificatessusing %s for CA file
)r	�bytesurl�supportedprotocols�config�insecureconnections�
configlist�
startswithrr$r�split�replace�lower�append�ssl�	CERT_NONE�
configbool�warnr
�
expandpath�os�path�exists�_defaultcacerts�debug�
CERT_REQUIRED)
�ui�hostname�	bhostname�sr+�defaultminimumprotocolr(�minimumprotocol�ciphers�fingerprints�fingerprint�alg�cafiler)r)r*�
_hostsettings>s�
�

�
�



���
���



���

rQcCsz|tvr
td|��tjtjB}|dkrn|dkr|tjO}n|dkr,|tjtjBO}nt�t	d���|t
tdd�O}|S)z8Return SSLContext options common to servers and clients.s protocol value not supported: %srrr�this should not happen�OP_NO_COMPRESSIONr)r#�
ValueErrorr;�OP_NO_SSLv2�OP_NO_SSLv3�OP_NO_TLSv1�
OP_NO_TLSv1_1rr$rr)rK�optionsr)r)r*�commonssloptions�srZcs�|s	t�td���dtjvr3zddl}|�t�tjd����	d�Wnt
y2��	d�Ynw��fD]}|rStj�
|�sStjtd�|t�|�ftd�d	��q7t�|�}t�td
�r�t�tj�}|d}	|	dkr�t���t�d
dt�tjj|_Wd�n1s�wYn6|	dkr�t���t�d
dt�tjj|_Wd�n1s�wYn|	dkr�tjj|_nt�td���|jttdd�O_nt�tj �}|jt!|d�O_d|_"|d|_#|d�r z|�$t�%|d��Wn%tj&�y}
ztjtd�t'�(|
j)d�td�|dd	��d}
~
ww�du�r4���fdd�}|�*��|�|ddu�r~z
|j+|dd�Wn5tj&�yz}
z't,|
j)�dk�r]|
j)d}n|
j)d}tjtd�|dt'�(|�ftd�d	��d}
~
wwd }
n|d!�r�|�-�d }
nd}
z	|j.||d"�}Wn�tj&�y9}
z�z|
�r�|dtj/k�r�|�0��s���1td#��Wntj&�y�Ynwt�|
d$��r4|
j2d%v�r#|ddk�r�t3dhk�r��1td&�t�|�d'�4t5t3��f����1td(�t�|�����1td)�|dt�|�f���1td*�t�|����1td+���|
j2d,k�r4tj6�r4��1td-���d}
~
ww|�7��sFt�8td.���|
||�d/�|_9|S)0a�Add SSL/TLS to a socket.

    This is a glorified wrapper for ``ssl.wrap_socket()``. It makes sane
    choices based on what security options are available.

    In addition to the arguments supported by ``ssl.wrap_socket``, we allow
    the following additional arguments:

    * serverhostname - The expected hostname of the remote server. If the
      server (and client) support SNI, this tells the server which certificate
      to use.
    s#serverhostname argument is requireds
SSLKEYLOGFILErNs8sslkeylog enabled by SSLKEYLOGFILE environment variable
s?sslkeylog module missing, but SSLKEYLOGFILE set in environment
s:certificate file (%s) does not exist; cannot connect to %ss:restore missing file or fix references in Mercurial configr!�PROTOCOL_TLS_CLIENTrr�ignore�"ssl.TLSVersion.TLSv1 is deprecatedr�$ssl.TLSVersion.TLSv1_1 is deprecatedrrRrSFrrscould not set ciphers: %ss#change cipher string (%s) in configcs�p�}��td�|d�S)Nspassphrase for %s: r.)�getpassr)�f��certfile�keyfilerFr)r*�passwordiszwrapsocket.<locals>.passwordr�rPrserror loading CA file %s: %ssfile is empty or malformed?Tr)�server_hostnames�(an attempt was made to load CA certificates but none were loaded; see https://mercurial-scm.org/wiki/SecureConnections for how to configure Mercurial to avoid this error)
sreason)�UNSUPPORTED_PROTOCOL�TLSV1_ALERT_PROTOCOL_VERSIONs�(could not communicate with %s using security protocols %s; if you are using a modern Mercurial version, consider contacting the operator of this server; see https://mercurial-scm.org/wiki/SecureConnections for more info)
�, s�(could not communicate with %s using TLS 1.0; the likely cause of this is the server no longer supports TLS 1.0 because it has known security vulnerabilities; see https://mercurial-scm.org/wiki/SecureConnections for more info)
s�(could not negotiate a common security protocol (%s+) with %s; the likely cause is Mercurial is configured to be more secure than the server can support)
s�(consider contacting the operator of this server and ask them to support modern TLS protocol versions; or, set hostsecurity.%s:minimumprotocol=tls1.0 to allow use of legacy, less secure protocols when communicating with this server)
sE(see https://mercurial-scm.org/wiki/SecureConnections for more info)
�CERTIFICATE_VERIFY_FAILEDsR(the full certificate chain may not be available locally; see "hg help debugssl")
sssl connection failed)�caloaded�hostname�settings�ui):rr$rr�environ�	sslkeylog�
set_keylogr	�fsdecode�
warnnoi18n�ImportErrorr@rArBr1rQr
�safehasattrr;�
SSLContextr[�warnings�catch_warnings�filterwarnings�DeprecationWarning�
TLSVersion�TLSv1�minimum_version�TLSv1_1�TLSv1_2rYr�PROTOCOL_SSLv23rZ�check_hostname�verify_mode�set_ciphers�sysstr�SSLErrorr
�forcebytestr�args�load_cert_chain�load_verify_locations�len�load_default_certs�wrap_socketrE�get_ca_certsr>�reasonr2r%r&�	iswindows�cipher�
SecurityError�_hgstate)�sockrcrbrF�serverhostnamerpr`�settings�
sslcontextrK�erd�msg�caloaded�	sslsocketr)rar*�
wrapsocketsN

��������
	

��
��

�����

����

�����	��	���D����5���������������
s�r�cCs|||fD]}|rtj�|�st�td�|��qt�td�r�t�	tj
�}|jttdd�O_|�
dd�}|dkrkdtvrEt�td���t���t�d	d
t�tjj|_tjj|_Wd�n1sewYn�|dkr�dtvrzt�td
���t���t�d	dt�tjj|_tjj|_Wd�n1s�wYn�|dkr�dtvr�t�td���tjj|_tjj|_nl|r�t�td�|��n`tj}	td�}
|�
dd�}|dkr�dtvr�t�td���tj}	n4|dkr�dtvr�t�td
���tj}	n!|dk�rdtv�r
t�td���tj}	n|�rt�td�|��t�	|	�}|j|
O_|jttdd�O_|jttdd�O_|�rE|�d�nt�td��r]|jttdd�O_|�tj�|�retj |_!ntj"|_!|�so|�rv|j#||d�|�r|j$|d�|j%|dd�S)a�Wrap a socket for use by servers.

    ``certfile`` and ``keyfile`` specify the files containing the certificate's
    public and private keys, respectively. Both keys can be defined in the same
    file via ``certfile`` (the private key must come first in the file).

    ``cafile`` defines the path to certificate authorities.

    ``requireclientcert`` specifies whether to require client certificates.

    Typically ``cafile`` is only defined if ``requireclientcert`` is true.
    s/referenced certificate file (%s) does not exist�PROTOCOL_TLS_SERVERrSrr0sserverexactprotocolrs$TLS 1.0 not supported by this Pythonr\r]Nrs$TLS 1.1 not supported by this Pythonr^rs$TLS 1.2 not supported by this Pythons)invalid value for serverexactprotocol: %s�OP_SINGLE_DH_USE�OP_SINGLE_ECDH_USE�DEFAULTs_RESTRICTED_SERVER_CIPHERS�OP_CIPHER_SERVER_PREFERENCE)rbrcreT)�server_side)&r@rArBrr$rr
rur;rvr�rYrr3r2rwrxryrzr{r|r}�maximum_versionr~rr�rZrrrr��_RESTRICTED_SERVER_CIPHERSrEr�r<r�r�r�)r�rFrbrcrP�requireclientcertr`r��
exactprotocolr'rYr)r)r*�wrapserversockets�
��

��

��

��


�

r�c@seZdZdZdS)�
wildcarderrorz2Represents an error parsing wildcards in DNS name.N)�__name__�
__module__�__qualname__�__doc__r)r)r)r*r�ysr�c
Cs
g}|sdSt�|�}t�|�}|�d�}|d}|dd�}|�d�}||kr0ttd�|��|s:|��|��kS|dkrD|�d�n|�d	�sN|�d	�rW|�t	�
|��n|�t	�
|��d
d��|D]
}|�t	�
|��qet�
dd
�|�dtj�}	|	�|�duS)z�Match DNS names according RFC 6125 section 6.4.3.

    This code is effectively copied from CPython's ssl._dnsname_match.

    Returns a bool indicating whether the expected hostname matches
    the value in ``dn``.
    F�.rrN�*s.too many wildcards in certificate DNS name: %ss[^.]+sxn--s\*s[^.]*s\As\.s\Z)r	r1r7�countr�rr9r:r6r
�reescaper8�re�compiler%�
IGNORECASE�match)
�dnrG�maxwildcards�pats�pieces�leftmost�	remainder�	wildcards�frag�patr)r)r*�
_dnsnamematch}s0




�r�cCs�|std�Sg}|�dg�}|D]5\}}|dkrEzt||�r"WdSWnty?}zt�|jd�WYd}~Sd}~ww|�|�q|s�|�dg�D]V}|D]Q\}}|dkr�z|�d�}Wnt	yrtd	�YSwzt||�r~WdSWnty�}zt�|jd�WYd}~Sd}~ww|�|�qRqNd
d�|D�}t
|�dkr�td
�d�|�St
|�dkr�td
�|dStd�S)z�Verify that cert (in socket.getpeercert() format) matches hostname.
    CRLs is not handled.

    Returns error message if any problems are found and None on success.
    sno certificate received�subjectAltName�DNSNr�subject�
commonName�asciis IDN in certificate not supportedcSsg|]}t�|��qSr))r	r1)�.0�dr)r)r*�
<listcomp>�sz_verifycert.<locals>.<listcomp>rscertificate is for %sris4no commonName or subjectAltName found in certificate)r�getr�r�r
r�r�r:�encode�UnicodeEncodeErrorr�r%)�certrG�dnsnames�sanr(�valuer��subr)r)r*�_verifycert�sT
� ��
��

�$��
��r�cCs>tjr
t��s
tjsdStj�tj���}|�	d�p|�	d�S)a@return true if this seems to be a pure Apple Python that
    * is unfrozen and presumably has the whole mercurial module in the file
      system
    * presumably is an Apple Python that uses Apple OpenSSL which has patches
      for using system certificate store CAs in addition to the provided
      cacerts file
    Fs/usr/bin/pythons,/system/library/frameworks/python.framework/)
r	�isdarwinr�
mainfrozen�
sysexecutabler@rA�realpathr9r6)�exer)r)r*�_plainapplepython�s	����r�c	Cs�zddl}|��}tj�|�r|�d�t�|�WSWntt	fy&Ynwt
�r@tj�tj�t�t
��d�}tj�|�r@|SdS)a�return path to default CA certificates or None.

    It is assumed this function is called when the returned certificates
    file will actually be used to validate connections. Therefore this
    function may print warnings or debug messages assuming this usage.

    We don't print a message when the Python is able to load default
    CA certs because this scenario is detected at socket connect time.
    rNs#using ca certificates from certifi
s
dummycert.pem)�certifi�wherer@rArBrDr	�fsencodert�AttributeErrorr�r%�dirname�__file__)rFr��certs�	dummycertr)r)r*rC�s"
���rCcCs|jd}t�|�}|jd}|jd}z|�d�}|��}Wnty/t�td�|��w|s;t�td�|��|drJ|�td�|�d	St	t
�|����t	t
�|����t	t
�|����d
�}dd�}d
||d�}	|dr�|dD]+\}
}||
��|kr�|�d||
||�f�|dr�|�td�|||	f�d	Sqy|dr�d}||d�}
nd}d|
|||
�f}
tjtd�||
ftd�|d��|jds�tjtd�|td�||	fd��t||�}|r�tjtd�||ftd�||	fd��d	S)zxValidate a socket meets security requirements.

    The passed socket must have been created with ``wrapsocket()``.
    rlrnrmTs%s ssl connection errors-%s certificate error: no certificate receivedrs�warning: connection security to %s is disabled per current settings; communication is susceptible to eavesdropping and tampering
N)r/�sha256ssha512cs$d��fdd�tdt��d�D��S)Nr-csg|]
}�||d��qS)�r))r��x�rIr)r*r�Jsz:validatesocket.<locals>.fmtfingerprint.<locals>.<listcomp>rr�)r%�ranger�r�r)r�r*�fmtfingerprintIs$z&validatesocket.<locals>.fmtfingerprints	sha256:%sr�rs)%s certificate matched fingerprint %s:%s
rs�(SHA-1 fingerprint for %s found in legacy [hostfingerprints] section; if you trust this fingerprint, remove the old SHA-1 fingerprint from [hostfingerprints] and add the following entry to the new [hostsecurity] section: %s:fingerprints=%s)
shostfingerprintr/r,s%s:%ss0certificate for %s has unexpected fingerprint %sscheck %s configurationr!rksPunable to verify security of %s (no loaded CA certificates); refusing to connects�see https://mercurial-scm.org/wiki/SecureConnections for how to configure Mercurial to avoid this error or set hostsecurity.%s:fingerprints=%s to trust this servers%s certificate error: %ss^set hostsecurity.%s:certfingerprints=%s config setting or use --insecure to connect insecurely)r�r	r1�getpeercertr�rr�rr>rr�sha1�digest�hashlib�sha256�sha512r9rDr�)r��shost�hostrFr��peercert�	peercert2�peerfingerprintsr��nicefingerprint�hashrN�section�nicer�r)r)r*�validatesockets�




�
������������
�
�����
����r�)N)NNNF)r)&�
__future__rr�r@r�r;rw�i18nrr	r�noder�rrr
�utilsrrr
r#�hassni�setr2ru�addrQrZr�r��	Exceptionr�r�r�r�rCr�r)r)r)r*�<module>sD	



2

�s
43#

https://t.me/RX1948 - 2025