Skip to content

Commit

Permalink
Add ClientResponse.certificate and populate it, if appropriate
Browse files Browse the repository at this point in the history
  • Loading branch information
auxsvr committed Jan 23, 2023
1 parent 4635161 commit 326a679
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES/2816.feature
@@ -0,0 +1 @@
Add `ClientResponse.certificate` and populate it, if appropriate.
1 change: 1 addition & 0 deletions CONTRIBUTORS.txt
Expand Up @@ -260,6 +260,7 @@ Pavol Vargovčík
Pawel Kowalski
Pawel Miech
Pepe Osca
Petros Blanis
Philipp A.
Pieter van Beek
Qiao Han
Expand Down
2 changes: 2 additions & 0 deletions aiohttp/client_reqrep.py
Expand Up @@ -698,6 +698,7 @@ def __init__(

self.method = method
self.cookies: SimpleCookie[str] = SimpleCookie()
self.certficate: Optional[Dict[str, Union[tuple, int, str]]] = None

self._real_url = url
self._url = url.with_fragment(None)
Expand Down Expand Up @@ -887,6 +888,7 @@ def _response_eof(self) -> None:
return

if self._connection is not None:
self.certificate = self._connection.transport.get_extra_info("peercert")
# websocket, protocol could be None because
# connection could be detached
if (
Expand Down
4 changes: 4 additions & 0 deletions docs/client_reference.rst
Expand Up @@ -1360,6 +1360,10 @@ Response object
objects of preceding requests (earliest request first) if there were
redirects, an empty sequence otherwise.

.. attribute:: certificate

The server certificate, if available.

.. method:: close()

Close response and underlying connection.
Expand Down

0 comments on commit 326a679

Please sign in to comment.