Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Possibility to get peer certificate when ClientResponseError is raised #10028

Open
1 task done
fed239 opened this issue Nov 23, 2024 · 1 comment
Open
1 task done

Possibility to get peer certificate when ClientResponseError is raised #10028

fed239 opened this issue Nov 23, 2024 · 1 comment

Comments

@fed239
Copy link

fed239 commented Nov 23, 2024

Is your feature request related to a problem?

We are not able to get peer certificate when ClientResponseError is raised.

Describe the solution you'd like

    try:
        async with aiohttp.ClientSession(
            timeout=aiohttp.ClientTimeout(total=60.0),
            request_class=Latin1HeadersClientRequest,
        ) as session:
        ...
    except aiohttp.ClientResponseError as e:
        sslobj = e.connection.transport.get_extra_info("ssl_object")  # <-- LIKE THIS

Describe alternatives you've considered

No alternative found

Related component

Client

Additional context

We need to perform advanced certificate validation for all response codes.

Code of Conduct

  • I agree to follow the aio-libs Code of Conduct
@asvetlov
Copy link
Member

In the snippet, transport is closed at the desired line; ssl_object doesn't exist.
Maybe we can extract a reference to ssl_object at the moment of raising the exception in ResponseHandler.lonnection_lost() from client_proto.py?

The patch looks trivial but I never tried it yet, and I have no idea what part of stores SSLObject is available after destroying the session and its SSLContext.
We need a champion for this issue.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants