aio-libs / aio-libs/aiohttp

Possibility to get peer certificate when ClientResponseError is raised

Open
#10,028 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
16.5k
Forks
2.4k
Avg merge
17h 22m
Merged PRs (30d)
212

Description

### 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

- [X] I agree to follow the aio-libs Code of Conduct

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.