OwlCyberSecurity - MANAGER
Edit File: pyopenssl.pyc
� ��abc�����������@@��s���d��Z��d�d�l�m�Z�d�d�l�Z�d�d�l�m�Z�d�d�l�m�Z �d�d�l �m�Z�d�d�l�m �Z �m�Z�d�d�l�m�Z�y�d�d �l�m�Z�Wn'�e�k �r��d�Z�d �d�l�m�Z�n�Xd�d�l�Z�d�d�l�Z�d �d�l�m�Z�d�d�l�Z�d �d �l�m�Z�d�d�g�Z�e�Z �i�e�j!�j"�e�j#�6e�j!�j$�e�j%�6Z&�e'�e�d���rie'�e�j!�d���rie�j!�j(�e&�e�j)�<n��e'�e�d���r�e'�e�j!�d���r�e�j!�j*�e&�e�j+�<n��y!�e&�j,�i�e�j!�j-�e�j.�6��Wn�e/�k �r�n�Xi�e�j!�j0�e�j1�6e�j!�j2�e�j3�6e�j!�j2�e�j!�j4�e�j5�6Z6�e7�d����e6�j8����D����Z9�d�Z:�e�j �Z;�e�j<�j=�Z>�e�j?�e@���ZA�d����ZB�d����ZC�d����ZD�d����ZE�d����ZF�d�eG�f�d�������YZH�e�r�d�d���ZI�n�e�ZI�eI�eH�_I�d�eG�f�d �������YZJ�d!����ZK�d�S("���sb�� SSL with SNI_-support for Python 2. Follow these instructions if you would like to verify SSL certificates in Python 2. Note, the default libraries do *not* do certificate checking; you need to do additional work to validate certificates yourself. This needs the following packages installed: * pyOpenSSL (tested with 16.0.0) * cryptography (minimum 1.3.4, from pyopenssl) * idna (minimum 2.0, from cryptography) However, pyopenssl depends on cryptography, which depends on idna, so while we use all three directly here we end up having relatively few packages required. You can install them with the following command: pip install pyopenssl cryptography idna To activate certificate checking, call :func:`~urllib3.contrib.pyopenssl.inject_into_urllib3` from your Python code before you begin making HTTP requests. This can be done in a ``sitecustomize`` module, or at any other time before your application begins using ``urllib3``, like this:: try: import urllib3.contrib.pyopenssl urllib3.contrib.pyopenssl.inject_into_urllib3() except ImportError: pass Now you can use :mod:`urllib3` as you normally would, and it will support SNI when the required modules are installed. Activating this module also has the positive side effect of disabling SSL/TLS compression in Python 2 (see `CRIME attack`_). If you want to configure the default list of supported cipher suites, you can set the ``urllib3.contrib.pyopenssl.DEFAULT_SSL_CIPHER_LIST`` variable. .. _sni: https://en.wikipedia.org/wiki/Server_Name_Indication .. _crime attack: https://en.wikipedia.org/wiki/CRIME_(security_exploit) i����(���t���absolute_importN(���t���x509(���t���backend(���t���_Certificate(���t���timeoutt���error(���t���BytesIO(���t���_fileobjecti���(���t���backport_makefile(���t���six(���t���utilt���inject_into_urllib3t���extract_from_urllib3t���PROTOCOL_TLSv1_1t���TLSv1_1_METHODt���PROTOCOL_TLSv1_2t���TLSv1_2_METHODc���������c@��s!���|��]�\�}�}�|�|�f�Vq�d��S(���N(����(���t���.0t���kt���v(����(����sI���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pys ���<genexpr>`���s����i�@��c�����������C@��sA���t�����t�t�j�_�t�t�_�t�t�j�_�t�t�_�t�t�j�_�d�S(���s7���Monkey-patch urllib3 with PyOpenSSL-backed SSL-support.N(���t���_validate_dependencies_mett���PyOpenSSLContextR ���t���ssl_t ���SSLContextt���HAS_SNIt���Truet���IS_PYOPENSSL(����(����(����sI���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyR���m���s���� c�����������C@��s:���t��t�j�_�t�t�_�t�t�j�_�t�t�_�t�t�j�_�d�S(���s4���Undo monkey-patching by :func:`inject_into_urllib3`.N(���t���orig_util_SSLContextR ���R���R���t���orig_util_HAS_SNIR���t���FalseR���(����(����(����sI���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyR���y���s ���� c����������C@��s{���d�d�l��m�}��t�|��d�d���d�k�r7�t�d�����n��d�d�l�m�}�|����}�t�|�d�d���d�k�rw�t�d�����n��d�S( ���s{��� Verifies that PyOpenSSL's package-level dependencies have been met. Throws `ImportError` if they are not met. i����(���t ���Extensionst���get_extension_for_classsX���'cryptography' module missing required functionality. Try upgrading to v1.3.4 or newer.(���t���X509t���_x509sS���'pyOpenSSL' module missing required functionality. Try upgrading to v0.14 or newer.N(���t���cryptography.x509.extensionsR���t���getattrt���Nonet���ImportErrort���OpenSSL.cryptoR ���(���R���R ���R���(����(����sI���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyR�������s���� c���������C@��s:���d����}�|�|����}��t��j�d�k�r6�|��j�d���}��n��|��S(���s��� Converts a dNSName SubjectAlternativeName field to the form used by the standard library on the given Python version. Cryptography produces a dNSName as a unicode string that was idna-decoded from ASCII bytes. We need to idna-encode that string to get it back, and then on Python 3 we also need to convert to unicode via UTF-8 (the stdlib uses PyUnicode_FromStringAndSize on it, which decodes via UTF-8). c���������S@��si���d�d�l��}�xM�d�d�g�D]?�}�|��j�|���r�|��t�|���}��|�j�d���|�j�|����Sq�W|�j�|����S(���s���� Borrowed wholesale from the Python Cryptography Project. It turns out that we can't just safely call `idna.encode`: it can explode for wildcard names. This avoids that problem. i����Nu���*.u���.t���ascii(���t���idnat ���startswitht���lent���encode(���t���nameR(���t���prefix(����(����sI���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyt���idna_encode����s����i���i����s���utf-8(���i���i����(���t���syst���version_infot���decode(���R,���R.���(����(����sI���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyt���_dnsname_to_stdlib����s ���� c���������C@��s����t��|��d���r�|��j����}�n�t�t�|��j���}�y�|�j�j�t�j���j �}�WnM�t�j �k �rc�g��St�j�t�j�t�j �t�f�k �r��}�t�j�d�|���g��SXg��|�j�t�j���D]�}�d�t�|���f�^�q��}�|�j�d����|�j�t�j���D����|�S(���sU��� Given an PyOpenSSL certificate, provides all the subject alternative names. t���to_cryptographys����A problem was encountered with the certificate that prevented urllib3 from finding the SubjectAlternativeName field. This can affect certificate validation. The error was %st���DNSc���������s@��s!���|��]�}�d��t��|���f�Vq�d�S(���s ���IP AddressN(���t���str(���R���R,���(����(����sI���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pys ���<genexpr>����s���(���t���hasattrR3���R���t���openssl_backendR!���t ���extensionsR���R���t���SubjectAlternativeNamet���valuet���ExtensionNotFoundt���DuplicateExtensiont���UnsupportedExtensiont���UnsupportedGeneralNameTypet���UnicodeErrort���logt���warningt���get_values_for_typet���DNSNameR2���t���extendt ���IPAddress(���t ���peer_certt���certt���extt���eR,���t���names(����(����sI���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyt���get_subj_alt_name����s(���� .t ���WrappedSocketc�����������B@��s����e��Z�d��Z�e�d���Z�d����Z�d����Z�d����Z�d����Z�d����Z �d����Z �d����Z�d ����Z�d ����Z �e�d���Z�d����Z�d ����Z�RS(���s����API-compatibility wrapper for Python OpenSSL's Connection-class. Note: _makefile_refs, _drop() and _reuse() are needed for the garbage collector of pypy. c���������C@��s1���|�|��_��|�|��_�|�|��_�d�|��_�t�|��_�d��S(���Ni����(���t ���connectiont���sockett���suppress_ragged_eofst���_makefile_refsR���t���_closed(���t���selfRM���RN���RO���(����(����sI���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyt���__init__����s ���� c���������C@��s ���|��j��j����S(���N(���RN���t���fileno(���RR���(����(����sI���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyRT�������s����c���������C@��s;���|��j��d�k�r!�|��j��d�8_��n��|��j�r7�|��j����n��d��S(���Ni����i���(���RP���RQ���t���close(���RR���(����(����sI���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyt���_decref_socketios����s���� c���������O@��s����y�|��j��j�|�|����}�Wn��t�j�j�k �rb�}�|��j�rM�|�j�d�k�rM�d�St�t�|�������n��t�j�j �k �r��}�|��j��j ����t�j�j�k�r��d�S���n^�t�j�j�k �r��t �j�|��j�|��j�j������}�|�s��t�d�����q��|��j�|�|����Sn�X|�Sd��S(���Ni����s���Unexpected EOFt����s���The read operation timed out(���i����s���Unexpected EOF(���RM���t���recvt���OpenSSLt���SSLt���SysCallErrorRO���t���argst���SocketErrorR5���t���ZeroReturnErrort���get_shutdownt���RECEIVED_SHUTDOWNt ���WantReadErrorR ���t ���wait_for_readRN���t ���gettimeoutR���(���RR���R\���t���kwargst���dataRI���t���rd(����(����sI���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyRX������s ����c���������O@��s����y�|��j��j�|�|����SWn��t�j�j�k �r`�}�|��j�rK�|�j�d�k�rK�d�St�t�|�������n��t�j�j �k �r��}�|��j��j ����t�j�j�k�r��d�S���nZ�t�j�j�k �r��t �j�|��j�|��j�j������}�|�s��t�d�����q��|��j�|�|����Sn�Xd��S(���Ni����s���Unexpected EOFi����s���The read operation timed out(���i����s���Unexpected EOF(���RM���t ���recv_intoRY���RZ���R[���RO���R\���R]���R5���R^���R_���R`���Ra���R ���Rb���RN���Rc���R���(���RR���R\���Rd���RI���Rf���(����(����sI���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyRg�����s����c���������C@��s���|��j��j�|���S(���N(���RN���t ���settimeout(���RR���R���(����(����sI���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyRh���*��s����c���������C@��s����x��t��r��y�|��j�j�|���SWq�t�j�j�k �ri�t�j�|��j�|��j�j ������}�|�s�t ������q�q�q�t�j�j�k �r��}�t�t �|�������q�Xq�Wd��S(���N(���R���RM���t���sendRY���RZ���t���WantWriteErrorR ���t���wait_for_writeRN���Rc���R���R[���R]���R5���(���RR���Re���t���wrRI���(����(����sI���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyt���_send_until_done-��s���� c���������C@��sG���d�}�x:�|�t��|���k��rB�|��j�|�|�|�t�!��}�|�|�7}�q �Wd��S(���Ni����(���R*���Rm���t���SSL_WRITE_BLOCKSIZE(���RR���Re���t ���total_sentt���sent(����(����sI���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyt���sendall9��s����c���������C@��s���|��j��j����d��S(���N(���RM���t���shutdown(���RR���(����(����sI���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyRr���?��s����c���������C@��sZ���|��j��d�k��rG�y�t�|��_�|��j�j����SWqV�t�j�j�k �rC�d��SXn�|��j��d�8_��d��S(���Ni���(���RP���R���RQ���RM���RU���RY���RZ���t���Error(���RR���(����(����sI���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyRU���C��s���� c���������C@��se���|��j��j����}�|�s�|�S|�r8�t�j�j�t�j�j�|���Si�d�|�j����j�f�f�f�d�6t�|���d�6S(���Nt ���commonNamet���subjectt���subjectAltName( ���RM���t���get_peer_certificateRY���t���cryptot���dump_certificatet ���FILETYPE_ASN1t���get_subjectt���CNRK���(���RR���t���binary_formR���(����(����sI���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyt���getpeercertM��s���� c���������C@��s���|��j��d�7_��d��S(���Ni���(���RP���(���RR���(����(����sI���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyt���_reuse_��s����c���������C@��s/���|��j��d�k��r�|��j����n�|��j��d�8_��d��S(���Ni���(���RP���RU���(���RR���(����(����sI���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyt���_dropb��s���� (���t���__name__t ���__module__t���__doc__R���RS���RT���RV���RX���Rg���Rh���Rm���Rq���Rr���RU���R���R~���R���R����(����(����(����sI���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyRL�������s��� i����c���������C@��s%���|��j��d�7_��t�|��|�|�d�t��S(���Ni���RU���(���RP���R���R���(���RR���t���modet���bufsize(����(����sI���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyt���makefilej��s����R���c�����������B@��s����e��Z�d��Z�d����Z�e�d������Z�e�j�d������Z�e�d������Z�e�j�d������Z�d����Z�d����Z �d�d�d�d���Z�d�d�d ���Z�e �e�e�d�d ���Z�RS(���s���� I am a wrapper class for the PyOpenSSL ``Context`` object. I am responsible for translating the interface of the standard library ``SSLContext`` object to calls into PyOpenSSL. c���������C@��s;���t��|�|��_�t�j�j�|��j���|��_�d�|��_�t�|��_�d��S(���Ni����( ���t���_openssl_versionst���protocolRY���RZ���t���Contextt���_ctxt���_optionsR���t���check_hostname(���RR���R����(����(����sI���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyRS���y��s���� c���������C@��s���|��j��S(���N(���R����(���RR���(����(����sI���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyt���options��s����c���������C@��s���|�|��_��|��j�j�|���d��S(���N(���R����R����t���set_options(���RR���R:���(����(����sI���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyR�������s���� c���������C@��s���t��|��j�j����S(���N(���t���_openssl_to_stdlib_verifyR����t���get_verify_mode(���RR���(����(����sI���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyt���verify_mode���s����c���������C@��s���|��j��j�t�|�t���d��S(���N(���R����t ���set_verifyt���_stdlib_to_openssl_verifyt���_verify_callback(���RR���R:���(����(����sI���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyR�������s���� c���������C@��s���|��j��j����d��S(���N(���R����t���set_default_verify_paths(���RR���(����(����sI���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyR�������s����c���������C@��s8���t��|�t�j���r$�|�j�d���}�n��|��j�j�|���d��S(���Ns���utf-8(���t ���isinstanceR ���t ���text_typeR+���R����t���set_cipher_list(���RR���t���ciphers(����(����sI���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyt���set_ciphers���s����c���������C@��sx���|�d��k �r�|�j�d���}�n��|�d��k �r<�|�j�d���}�n��|��j�j�|�|���|�d��k �rt�|��j�j�t�|�����n��d��S(���Ns���utf-8(���R$���R+���R����t���load_verify_locationsR���(���RR���t���cafilet���capatht���cadata(����(����sI���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyR�������s����c���������@��sR���|��j��j�|������d��k �r8�|��j��j����f�d������n��|��j��j�|�pJ�|���d��S(���Nc���������@��s������S(���N(����(���t ���max_lengtht���prompt_twicet���userdata(���t���password(����sI���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyt���<lambda>���RW���(���R����t���use_certificate_fileR$���t ���set_passwd_cbt���use_privatekey_file(���RR���t���certfilet���keyfileR����(����(���R����sI���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyt���load_cert_chain���s����c��� ������C@��s���t��j�j�|��j�|���}�t�|�t�j���r<�|�j�d���}�n��|�d��k �rX�|�j �|���n��|�j ����x��t�r��y�|�j����Wnr�t��j�j �k �r��t�j�|�|�j������}�|�se�t�d�����qe�qe�n,�t��j�j�k �r��}�t�j�d�|�����n�XPqe�Wt�|�|���S(���Ns���utf-8s���select timed outs���bad handshake: %r(���RY���RZ���t ���ConnectionR����R����R ���R����R+���R$���t���set_tlsext_host_namet���set_connect_stateR���t���do_handshakeRa���R ���Rb���Rc���R���Rs���t���sslt���SSLErrorRL���( ���RR���t���sockt���server_sidet���do_handshake_on_connectRO���t���server_hostnamet���cnxRf���RI���(����(����sI���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyt���wrap_socket���s$���� N(���R����R����R����RS���t���propertyR����t���setterR����R����R����R$���R����R����R���R���R����(����(����(����sI���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyR���s��s��� c���������C@��s ���|�d�k�S(���Ni����(����(���R����R���t���err_not ���err_deptht���return_code(����(����sI���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyR�������s����(L���R����t ���__future__R����t���OpenSSL.SSLRY���t���cryptographyR���t$���cryptography.hazmat.backends.opensslR���R7���t)���cryptography.hazmat.backends.openssl.x509R���RN���R���R���R]���t���ioR���R���R%���R$���t���packages.backports.makefileR���t���loggingR����t���packagesR ���R/���RW���R ���t���__all__R���R���RZ���t ���SSLv23_METHODt���PROTOCOL_SSLv23t���TLSv1_METHODt���PROTOCOL_TLSv1R����R6���R���R ���R���R���t���updatet���SSLv3_METHODt���PROTOCOL_SSLv3t���AttributeErrort���VERIFY_NONEt ���CERT_NONEt���VERIFY_PEERt ���CERT_OPTIONALt���VERIFY_FAIL_IF_NO_PEER_CERTt ���CERT_REQUIREDR����t���dictt���itemsR����Rn���R���R���R���R���t ���getLoggerR����R@���R���R���R���R2���RK���t���objectRL���R����R���R����(����(����(����sI���/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.pyt���<module>+���sh��� !!! 3� S