o
    'h                  
   @  s  U d Z ddlmZ ddlZddlZddlmZmZmZ ddl	m
Z
 dZdZzddlmZ W n# eefyP Z zdZeeerFejded	d
 W Y dZ[ndZ[ww zddlmZ W n eyd   dZY nw erddlZddlmZmZ dZerejZde d< ej!ej! Z!de d< ej"ej"fZ"de d< ej#ej#fZ#de d< nejZej!Z!ej"fZ"ej#fZ#ejZe"Z$d'ddZ%d(d d!Z&dS G d"d# d#e'ZdZd$Z!d'd%dZ%d&d! Z&dS ))zSupport for SSL in PyMongo.    )annotationsN)AnyOptionalUnionConfigurationErrorTFzFailed to use the installed version of PyOpenSSL. Falling back to stdlib ssl, disabling OCSP support. This is likely caused by incompatible versions of PyOpenSSL < 23.2.0 and cryptography >= 42.0.0. Try updating PyOpenSSL >= 23.2.0 to enable OCSP.   )
stacklevel)	CERT_NONECERT_REQUIREDr   
PYSSLErrortupleBLOCKING_IO_ERRORSBLOCKING_IO_READ_ERRORBLOCKING_IO_WRITE_ERRORis_syncboolreturnc                 C  s   | rt rtjS tjS )N)
HAVE_PYSSL_pysslHAS_SNI_sslr    r   O/var/www/html/olx_land/venv/lib/python3.10/site-packages/pymongo/ssl_support.py_has_sniI   s   r   certfileOptional[str]
passphraseca_certscrlfileallow_invalid_certificatesallow_invalid_hostnamesdisable_ocsp_endpoint_check)Union[_pyssl.SSLContext, _ssl.SSLContext]c              
   C  s@  |rt rt}nt}|rtnt}	||j}
|	tkr| |
_nd|
_t|
dr*| |
_	t|
drO|
 j
|jO  _
|
 j
|jO  _
|
 j
|jO  _
|
 j
|jO  _
| durrz	|
| d| W n |jyq } ztd| dd}~ww |dur|jr}tdt|dd|
_|
| |dur|
| n|	tkr|
  |	|
_|
S )	z'Create and return an SSLContext object.Fcheck_ocsp_endpointoptionsNz'Private key doesn't match certificate: z(tlsCRLFile cannot be used with PyOpenSSLVERIFY_CRL_CHECK_LEAFr   )r   r   r   r
   r   
SSLContextPROTOCOL_SSLv23check_hostnamehasattrr%   r&   OP_NO_SSLv2OP_NO_SSLv3OP_NO_COMPRESSIONOP_NO_RENEGOTIATIONload_cert_chainSSLErrorr   IS_PYOPENSSLgetattrverify_flagsload_verify_locationsload_default_certsverify_mode)r   r   r   r    r!   r"   r#   r   sslr7   ctxexcr   r   r   get_ssl_contextN   sB   



r;   c                   @  s   e Zd ZdS )r1   N)__name__
__module____qualname__r   r   r   r   r1      s    r1   r   c                 C  s   dS )NFr   r   r   r   r   r      s   c                  G  s   t d)z(No ssl module, raise ConfigurationError.zThe ssl module is not availabler   )dummyr   r   r   r;      s   )r   r   r   r   )r   r   r   r   r   r   r    r   r!   r   r"   r   r#   r   r   r   r   r$   )(__doc__
__future__r   typeswarningstypingr   r   r   pymongo.errorsr   HAVE_SSLr   pymongo.pyopenssl_contextpyopenssl_contextr   ImportErrorAttributeErrorr:   
isinstancewarnUserWarningpymongo.ssl_contextssl_contextr   r8   
_stdlibsslr
   r   IPADDR_SAFEr1   r   __annotations__r   r   r   BLOCKING_IO_LOOKUP_ERRORr   r;   	Exceptionr   r   r   r   <module>   sb   

4
