HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //lib/python3.6/site-packages/S3/__pycache__/ConnMan.cpython-36.opt-1.pyc
3

�9pe�3�@s�ddlmZddlZejdkr,ddlmZnddlmZddlZddlm	Z	ddl
mZddlmZydd	l
m
Z
Wn ek
r�dd	lm
Z
YnXdd
lmZddlmZmZddlmZd
gZGdd�de�ZGdd
�d
e�ZdS)�)�absolute_importN��)�httplib)�debug)�	Semaphore)�time)�urlparse)�Config)�ParameterError�S3SSLCertificateError)�getBucketFromHostname�ConnManc@sjeZdZdZdZedd��Zedd��Zedd��Zed	d
��Z	dd�Z
d
d�Zeddd��Zdd�Z
dS)�http_connectionNFcCsNt�}d}ytj|d�}Wntk
r.YnX|rJ|jrJd|_td�|S)N)�cafileFz+Disabling SSL certificate hostname checking)r
�sslZcreate_default_context�AttributeError�check_ssl_hostname�check_hostnamer)r�cfg�context�r�/usr/lib/python3.6/ConnMan.py�_ssl_verified_context,sz%http_connection._ssl_verified_contextcCs:td�d}ytj|tjd�}Wntk
r4YnX|S)Nz"Disabling SSL certificate checking)r�	cert_reqs)rr�_create_unverified_context�	CERT_NONEr)rrrrr�_ssl_unverified_context:sz'http_connection._ssl_unverified_contextcCsDd}y&|rtjntj}tj||||d�}Wntk
r>YnX|S)N)r�keyfile�certfiler)rZ
CERT_REQUIREDrrr)rrZcheck_server_certrrrrrr�_ssl_client_auth_contextEsz(http_connection._ssl_client_auth_contextcCs�tjrtjSt�}|j}|dkr$d}|jp,d}|jp6d}td|�td|�td|�|dk	rrtj|||j	|�}n|j	r�tj
|�}n
tj|�}|t_dt_|S)N�zUsing ca_certs_file %szUsing ssl_client_cert_file %szUsing ssl_client_key_file %sT)r�context_setrr
Z
ca_certs_fileZssl_client_cert_fileZssl_client_key_filerr �check_ssl_certificaterr)rrrrrrrr�_ssl_contextRs&





zhttp_connection._ssl_contextcCs�td�|jdf�}|j�}tdtj�j}x�|D]�\}}|dkr2|j�}|jd�rh|jd�rh|jd�s||jd�r�|jd�r�dS||d	tj	j�d
�kr2|j|dtj	j�d
��r2dSq2WdS)
a�
        Wildcard matching for *.s3.amazonaws.com and similar per region.

        Per http://docs.aws.amazon.com/AmazonS3/latest/dev/BucketRestrictions.html:
        "We recommend that all bucket names comply with DNS naming conventions."

        Per http://docs.aws.amazon.com/AmazonS3/latest/dev/VirtualHosting.html:
        "When using virtual hosted-style buckets with SSL, the SSL
        wild card certificate only matches buckets that do not contain
        periods. To work around this, use HTTP or write your own
        certificate verification logic."

        Therefore, we need a custom validation routine that allows
        mybucket.example.com.s3.amazonaws.com to be considered a valid
        hostname for the *.s3.amazonaws.com wildcard cert, and for the
        region-specific *.s3-[region].amazonaws.com wildcard cert.

        We also forgive non-S3 wildcard certificates should the
        hostname match, to allow compatibility with other S3
        API-compatible storage providers.
        z6checking SSL subjectAltName as forgiving wildcard certZsubjectAltNamezhttps://ZDNSz*.s3z.amazonaws.comz.amazonaws.com.cnT�*)Zbucket�locationr!F)
r�get�lowerr	r
Zhost_bucket�hostname�
startswith�endswithZbucket_location)�self�certr)ZsanZcleaned_host_bucket_config�key�valuerrr�forgive_wildcard_certms"
z%http_connection.forgive_wildcard_certcCs||jjj�}ytj||j�WnXtk
r2dStk
rDdStk
rv}z|j	||j�sf|�WYdd}~XnXdS)N)
�cZsockZgetpeercertr�match_hostnamer)r�
ValueErrorZS3CertificateErrorr0)r,r-�errrr2�szhttp_connection.match_hostnamecCs�yftj�}t|�\}}|r:d|kr:td�d}|rJd|_n|rF|j}nd}tj||||d�}td�WnZtk
r�ytj|||d�}td�Wn(tk
r�tj||�}td	�YnXYnX|S)
N�.zHBucket name contains "." character, disabling initial SSL hostname checkFT)rrz=httplib.HTTPSConnection() has both context and check_hostname)rz*httplib.HTTPSConnection() has only contextz@httplib.HTTPSConnection() has neither context nor check_hostname)rr$r
rrrZHTTPSConnection�	TypeError)r)�portrZbucket_name�successr�connrrr�_https_connection�s*z!http_connection._https_connectioncCs8||_||_d|_td|�}|j|_|j|_|jrZ|jdkrZ|jjd�|_td|j�nd|_|j	s�|r�t
j|j|j�|_td|j|j�n"t
j|j|j�|_td|j|j�nz|�r
t
j|j	|j�|_td|j	|j�|jr�|jp�d}|jj|j|�td	|j|�n"t
j|j	|j�|_td
|j	|j�t�|_dS)Nrzhttps://�/zendpoint path set to %sz#non-proxied HTTPSConnection(%s, %s)z"non-proxied HTTPConnection(%s, %s)zproxied HTTPSConnection(%s, %s)i�ztunnel to %s, %szproxied HTTPConnection(%s, %s))r�id�counterr	r)r7�path�rstripr�
proxy_hostrr:r1rZHTTPConnection�
proxy_portZ
set_tunnelr�last_used_time)r,r<r)rrZparsed_hostnamer7rrr�__init__�s2zhttp_connection.__init__)N)�__name__�
__module__�__qualname__rr"�staticmethodrrr r$r0r2r:rCrrrrr(s
($rc@sLeZdZejZejZe�ZiZdZ	e
d	dd��Ze
dd��Ze
dd��Z
dS)
ri NcCsLt�}|dkr|j}d}|jdkrJ|r8tjdkr8td��d|j|jf}nd|rTdpVd|f}tjj	�|tj
kr|gtj
|<xhtj
|r�tj
|j�}t�}||j
|jkr�||j
kr�td|j|jf�Ptd�tj|�d}q~Wtjj�|�s:td	|�t||||�}|jj�|j�r:|j�r:|j�r:|j�|jd
7_|S)Nr!iz6use_https=True can't be used with proxy on Python <2.7z
proxy://%s:%szhttp%s://%s�sz)ConnMan.get(): re-using connection: %s#%dz)ConnMan.get(): closing expired connectionz*ConnMan.get(): creating new connection: %sr)r
Z	use_httpsr@�sys�
hexversionrrAr�
conn_pool_sem�acquire�	conn_pool�poprrBZconnection_max_agerr<r=�close�releaserr1Zconnectrr#rr2)r)rrr9Zconn_idZcur_timerrrr's@







zConnMan.getcCs�|jjd�r"tj|�td�dS|jtjkrDtj|�td�dSt�}|jsftj|�td�dSt	�|_
tjj�tj
|jj|�tjj�td|j|jf�dS)Nzproxy://zFConnMan.put(): closing proxy connection (keep-alive not yet supported)z+ConnMan.put(): closing over-used connectionz?ConnMan.put(): closing connection (connection pooling disabled)z2ConnMan.put(): connection put back to pool (%s#%d))r<r*rrOrr=�conn_max_counterr
Zconnection_poolingrrBrKrLrM�appendrP)r9rrrr�put&s&




zConnMan.putcCs|r|jj�dS)N)r1rO)r9rrrrOBsz
ConnMan.close)N)rDrErFrZ_CS_REQ_SENTZCONTINUErrKrMrQrGr'rSrOrrrrr�s%)rr)Z
__future__rrI�version_infoZCustom_httplib3xrZCustom_httplib27rZloggingrZ	threadingrrr	�ImportErrorZurllib.parser
Z
ExceptionsrrZUtilsr
�__all__�objectrrrrrr�<module>
s&
R