Wie behebe ich den Fehler UNSAFE_LEGACY_RENEGOTIATION_DISABLED mit httpx?Python

Python-Programme
Anonymous
 Wie behebe ich den Fehler UNSAFE_LEGACY_RENEGOTIATION_DISABLED mit httpx?

Post by Anonymous »

Bei Anfrage (Python 3.13):

Code: Select all

import asyncio

from httpx import AsyncClient
from httpx_ntlm import HttpNtlmAuth

username = 'username'
password = 'password'

async def make_request():
client = AsyncClient(auth=HttpNtlmAuth(username, password))
resp = await client.get("https://my-url.com/my-path?inn=12334")

asyncio.run(make_request())
Ich erhalte eine Fehlermeldung zu UNSAFE_LEGACY_RENEGOTIATION_DISABLED:

Code: Select all

Traceback (most recent call last):
File "/Users/albertaleksandrov/Library/Caches/pypoetry/virtualenvs/песочница-zMN9kpQl-py3.13/lib/python3.13/site-packages/httpx/_transports/default.py", line 101, in map_httpcore_exceptions
yield
File "/Users/albertaleksandrov/Library/Caches/pypoetry/virtualenvs/песочница-zMN9kpQl-py3.13/lib/python3.13/site-packages/httpx/_transports/default.py", line 394, in handle_async_request
resp = await self._pool.handle_async_request(req)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/albertaleksandrov/Library/Caches/pypoetry/virtualenvs/песочница-zMN9kpQl-py3.13/lib/python3.13/site-packages/httpcore/_async/connection_pool.py", line 256, in handle_async_request
raise exc from None
File "/Users/albertaleksandrov/Library/Caches/pypoetry/virtualenvs/песочница-zMN9kpQl-py3.13/lib/python3.13/site-packages/httpcore/_async/connection_pool.py", line 236, in handle_async_request
response = await connection.handle_async_request(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pool_request.request
^^^^^^^^^^^^^^^^^^^^
)
^
File "/Users/albertaleksandrov/Library/Caches/pypoetry/virtualenvs/песочница-zMN9kpQl-py3.13/lib/python3.13/site-packages/httpcore/_async/connection.py", line 101, in handle_async_request
raise exc
File "/Users/albertaleksandrov/Library/Caches/pypoetry/virtualenvs/песочница-zMN9kpQl-py3.13/lib/python3.13/site-packages/httpcore/_async/connection.py", line 78, in handle_async_request
stream = await self._connect(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/albertaleksandrov/Library/Caches/pypoetry/virtualenvs/песочница-zMN9kpQl-py3.13/lib/python3.13/site-packages/httpcore/_async/connection.py", line 156, in _connect
stream = await stream.start_tls(**kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/albertaleksandrov/Library/Caches/pypoetry/virtualenvs/песочница-zMN9kpQl-py3.13/lib/python3.13/site-packages/httpcore/_backends/anyio.py", line 67, in start_tls
with map_exceptions(exc_map):
~~~~~~~~~~~~~~^^^^^^^^^
File "/opt/homebrew/Cellar/[email protected]/3.13.2/Frameworks/Python.framework/Versions/3.13/lib/python3.13/contextlib.py", line 162, in __exit__
self.gen.throw(value)
~~~~~~~~~~~~~~^^^^^^^
File "/Users/albertaleksandrov/Library/Caches/pypoetry/virtualenvs/песочница-zMN9kpQl-py3.13/lib/python3.13/site-packages/httpcore/_exceptions.py", line 14, in map_exceptions
raise to_exc(exc) from exc
httpcore.ConnectError: [SSL:  UNSAFE_LEGACY_RENEGOTIATION_DISABLED] unsafe legacy renegotiation disabled (_ssl.c:1028)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/Users/albertaleksandrov/PycharmProjects/Песочница/sc/get_result.py", line 21, in 
asyncio.run(make_request())
~~~~~~~~~~~^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/[email protected]/3.13.2/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/runners.py", line 195, in run
return runner.run(main)
~~~~~~~~~~^^^^^^
File "/opt/homebrew/Cellar/[email protected]/3.13.2/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File "/opt/homebrew/Cellar/[email protected]/3.13.2/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/base_events.py", line 725, in run_until_complete
return future.result()
~~~~~~~~~~~~~^^
File "/Users/albertaleksandrov/PycharmProjects/Песочница/sc/get_result.py", line 16, in make_request
resp = await client.get(
^^^^^^^^^^^^^^^^^
"https://tportal.x5.ru/compliance/rpc/_vti_bin/X5.Portal.Site.RPCParticipants/DataService.svc/GetRelatedCA?inn=7727797631"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/Users/albertaleksandrov/Library/Caches/pypoetry/virtualenvs/песочница-zMN9kpQl-py3.13/lib/python3.13/site-packages/httpx/_client.py", line 1768, in get
return await self.request(
^^^^^^^^^^^^^^^^^^^
......
)
^
File "/Users/albertaleksandrov/Library/Caches/pypoetry/virtualenvs/песочница-zMN9kpQl-py3.13/lib/python3.13/site-packages/httpx/_client.py", line 1540, in request
return await self.send(request, auth=auth, follow_redirects=follow_redirects)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/albertaleksandrov/Library/Caches/pypoetry/virtualenvs/песочница-zMN9kpQl-py3.13/lib/python3.13/site-packages/httpx/_client.py", line 1629, in send
response = await self._send_handling_auth(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
......
)
^
File "/Users/albertaleksandrov/Library/Caches/pypoetry/virtualenvs/песочница-zMN9kpQl-py3.13/lib/python3.13/site-packages/httpx/_client.py", line 1657, in _send_handling_auth
response = await self._send_handling_redirects(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
......
)
^
File "/Users/albertaleksandrov/Library/Caches/pypoetry/virtualenvs/песочница-zMN9kpQl-py3.13/lib/python3.13/site-packages/httpx/_client.py", line 1694, in _send_handling_redirects
response = await self._send_single_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/albertaleksandrov/Library/Caches/pypoetry/virtualenvs/песочница-zMN9kpQl-py3.13/lib/python3.13/site-packages/httpx/_client.py", line 1730, in _send_single_request
response = await transport.handle_async_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/albertaleksandrov/Library/Caches/pypoetry/virtualenvs/песочница-zMN9kpQl-py3.13/lib/python3.13/site-packages/httpx/_transports/default.py", line 393, in handle_async_request
with map_httpcore_exceptions():
~~~~~~~~~~~~~~~~~~~~~~~^^
File "/opt/homebrew/Cellar/[email protected]/3.13.2/Frameworks/Python.framework/Versions/3.13/lib/python3.13/contextlib.py", line 162, in __exit__
self.gen.throw(value)
~~~~~~~~~~~~~~^^^^^^^
File "/Users/albertaleksandrov/Library/Caches/pypoetry/virtualenvs/песочница-zMN9kpQl-py3.13/lib/python3.13/site-packages/httpx/_transports/default.py", line 118, in map_httpcore_exceptions
raise mapped_exc(message) from exc
httpx.ConnectError: [SSL:  UNSAFE_LEGACY_RENEGOTIATION_DISABLED] unsafe legacy renegotiation disabled (_ssl.c:1028)
Dann habe ich die SSL-Konfiguration hinzugefügt:

Code: Select all

import asyncio
import ssl

from httpx import AsyncClient
from httpx_ntlm import HttpNtlmAuth

username = 'username'
password = 'password'

async def make_request():
context = ssl.create_default_context(ssl.Purpose.SERVER_AUTH)
context.options |= ssl.OP_LEGACY_SERVER_CONNECT
client = AsyncClient(auth=HttpNtlmAuth(username, password), verify=context)
resp = await client.get("https://my-url.com/my-path?inn=12334")

asyncio.run(make_request())
Aber danach erhalte ich eine weitere Fehlermeldung:

Code: Select all

Traceback (most recent call last):
File "/Users/albertaleksandrov/Library/Caches/pypoetry/virtualenvs/песочница-zMN9kpQl-py3.13/lib/python3.13/site-packages/httpx/_transports/default.py", line 101, in map_httpcore_exceptions
yield
File "/Users/albertaleksandrov/Library/Caches/pypoetry/virtualenvs/песочница-zMN9kpQl-py3.13/lib/python3.13/site-packages/httpx/_transports/default.py", line 271, in __aiter__
async for part in self._httpcore_stream:
yield part
File "/Users/albertaleksandrov/Library/Caches/pypoetry/virtualenvs/песочница-zMN9kpQl-py3.13/lib/python3.13/site-packages/httpcore/_async/connection_pool.py", line 407, in __aiter__
raise exc from None
File "/Users/albertaleksandrov/Library/Caches/pypoetry/virtualenvs/песочница-zMN9kpQl-py3.13/lib/python3.13/site-packages/httpcore/_async/connection_pool.py", line 403, in __aiter__
async for part in self._stream:
yield part
File "/Users/albertaleksandrov/Library/Caches/pypoetry/virtualenvs/песочница-zMN9kpQl-py3.13/lib/python3.13/site-packages/httpcore/_async/http11.py", line 342, in __aiter__
raise exc
File "/Users/albertaleksandrov/Library/Caches/pypoetry/virtualenvs/песочница-zMN9kpQl-py3.13/lib/python3.13/site-packages/httpcore/_async/http11.py", line 334, in __aiter__
async for chunk in self._connection._receive_response_body(**kwargs):
yield chunk
File "/Users/albertaleksandrov/Library/Caches/pypoetry/virtualenvs/песочница-zMN9kpQl-py3.13/lib/python3.13/site-packages/httpcore/_async/http11.py", line 203, in _receive_response_body
event = await self._receive_event(timeout=timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/albertaleksandrov/Library/Caches/pypoetry/virtualenvs/песочница-zMN9kpQl-py3.13/lib/python3.13/site-packages/httpcore/_async/http11.py", line 217, in _receive_event
data = await self._network_stream.read(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
self.READ_NUM_BYTES, timeout=timeout
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/Users/albertaleksandrov/Library/Caches/pypoetry/virtualenvs/песочница-zMN9kpQl-py3.13/lib/python3.13/site-packages/httpcore/_backends/anyio.py", line 32, in read
with map_exceptions(exc_map):
~~~~~~~~~~~~~~^^^^^^^^^
File "/opt/homebrew/Cellar/[email protected]/3.13.2/Frameworks/Python.framework/Versions/3.13/lib/python3.13/contextlib.py", line 162, in __exit__
self.gen.throw(value)
~~~~~~~~~~~~~~^^^^^^^
File "/Users/albertaleksandrov/Library/Caches/pypoetry/virtualenvs/песочница-zMN9kpQl-py3.13/lib/python3.13/site-packages/httpcore/_exceptions.py", line 14, in map_exceptions
raise to_exc(exc) from exc
httpcore.ReadError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/Users/albertaleksandrov/PycharmProjects/Песочница/sc/get_result.py", line 20, in 
asyncio.run(make_request())
~~~~~~~~~~~^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/[email protected]/3.13.2/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/runners.py", line 195, in run
return runner.run(main)
~~~~~~~~~~^^^^^^
File "/opt/homebrew/Cellar/[email protected]/3.13.2/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File "/opt/homebrew/Cellar/[email protected]/3.13.2/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/base_events.py", line 725, in run_until_complete
return future.result()
~~~~~~~~~~~~~^^
File "/Users/albertaleksandrov/PycharmProjects/Песочница/sc/get_result.py", line 15,  in make_request
resp = await client.get(
^^^^^^^^^^^^^^^^^
"https://tportal.x5.ru/compliance/rpc/_vti_bin/X5.Portal.Site.RPCParticipants/DataService.svc/GetRelatedCA?inn=7727797631"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/Users/albertaleksandrov/Library/Caches/pypoetry/virtualenvs/песочница-zMN9kpQl-py3.13/lib/python3.13/site-packages/httpx/_client.py", line 1768, in get
return await self.request(
^^^^^^^^^^^^^^^^^^^
......
)
^
File "/Users/albertaleksandrov/Library/Caches/pypoetry/virtualenvs/песочница-zMN9kpQl-py3.13/lib/python3.13/site-packages/httpx/_client.py", line 1540, in request
return await self.send(request, auth=auth, follow_redirects=follow_redirects)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/albertaleksandrov/Library/Caches/pypoetry/virtualenvs/песочница-zMN9kpQl-py3.13/lib/python3.13/site-packages/httpx/_client.py", line 1629, in send
response = await self._send_handling_auth(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
......
)
^
File "/Users/albertaleksandrov/Library/Caches/pypoetry/virtualenvs/песочница-zMN9kpQl-py3.13/lib/python3.13/site-packages/httpx/_client.py", line 1675, in _send_handling_auth
raise exc
File "/Users/albertaleksandrov/Library/Caches/pypoetry/virtualenvs/песочница-zMN9kpQl-py3.13/lib/python3.13/site-packages/httpx/_client.py", line 1669, in _send_handling_auth
await response.aread()
File "/Users/albertaleksandrov/Library/Caches/pypoetry/virtualenvs/песочница-zMN9kpQl-py3.13/lib/python3.13/site-packages/httpx/_models.py", line 979, in aread
self._content = b"".join([part async for part in self.aiter_bytes()])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/albertaleksandrov/Library/Caches/pypoetry/virtualenvs/песочница-zMN9kpQl-py3.13/lib/python3.13/site-packages/httpx/_models.py", line 997, in aiter_bytes
async for raw_bytes in self.aiter_raw():
......
yield chunk
File "/Users/albertaleksandrov/Library/Caches/pypoetry/virtualenvs/песочница-zMN9kpQl-py3.13/lib/python3.13/site-packages/httpx/_models.py", line 1055, in aiter_raw
async for raw_stream_bytes in self.stream:
......
yield chunk
File "/Users/albertaleksandrov/Library/Caches/pypoetry/virtualenvs/песочница-zMN9kpQl-py3.13/lib/python3.13/site-packages/httpx/_client.py", line 176, in __aiter__
async for chunk in self._stream:
yield chunk
File "/Users/albertaleksandrov/Library/Caches/pypoetry/virtualenvs/песочница-zMN9kpQl-py3.13/lib/python3.13/site-packages/httpx/_transports/default.py", line 270, in __aiter__
with map_httpcore_exceptions():
~~~~~~~~~~~~~~~~~~~~~~~^^
File "/opt/homebrew/Cellar/[email protected]/3.13.2/Frameworks/Python.framework/Versions/3.13/lib/python3.13/contextlib.py", line 162, in __exit__
self.gen.throw(value)
~~~~~~~~~~~~~~^^^^^^^
File "/Users/albertaleksandrov/Library/Caches/pypoetry/virtualenvs/песочница-zMN9kpQl-py3.13/lib/python3.13/site-packages/httpx/_transports/default.py", line 118, in map_httpcore_exceptions
raise mapped_exc(message) from exc
httpx.ReadError
Wie behebe ich den Fehler UNSAFE_LEGACY_RENEGOTIATION_DISABLED mit httpx?

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post