[3.13] gh-118658: Return consistent types from get_un/verified_chain in SSLObject and SSLSocket (GH-118669) (#123082)

gh-118658: Return consistent types from `get_un/verified_chain` in `SSLObject` and `SSLSocket` (GH-118669)
(cherry picked from commit 8ef358dae1)

Co-authored-by: Mateusz Nowak <nowak.mateusz@hotmail.com>
Co-authored-by: Gregory P. Smith [Google LLC] <greg@krypto.org>
This commit is contained in:
Miss Islington (bot) 2024-08-19 17:39:28 +02:00 committed by GitHub
parent 0a02026a08
commit 21399a0963
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 86 additions and 2 deletions

View file

@ -1165,11 +1165,21 @@ class SSLSocket(socket):
@_sslcopydoc
def get_verified_chain(self):
return self._sslobj.get_verified_chain()
chain = self._sslobj.get_verified_chain()
if chain is None:
return []
return [cert.public_bytes(_ssl.ENCODING_DER) for cert in chain]
@_sslcopydoc
def get_unverified_chain(self):
return self._sslobj.get_unverified_chain()
chain = self._sslobj.get_unverified_chain()
if chain is None:
return []
return [cert.public_bytes(_ssl.ENCODING_DER) for cert in chain]
@_sslcopydoc
def selected_npn_protocol(self):