summaryrefslogtreecommitdiffstats
path: root/Lib/ssl.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2024-08-19 15:39:28 (GMT)
committerGitHub <noreply@github.com>2024-08-19 15:39:28 (GMT)
commit21399a096302ea577efd9a12c2f08b4458d095bd (patch)
treeb0593057e3ddf375a34e48bee76d1fb82b42b9ee /Lib/ssl.py
parent0a02026a084213cbd09c66534c55104ab460c686 (diff)
downloadcpython-21399a096302ea577efd9a12c2f08b4458d095bd.zip
cpython-21399a096302ea577efd9a12c2f08b4458d095bd.tar.gz
cpython-21399a096302ea577efd9a12c2f08b4458d095bd.tar.bz2
[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 8ef358dae1959e2aff8b04fb69b8a36d6da6847a) Co-authored-by: Mateusz Nowak <nowak.mateusz@hotmail.com> Co-authored-by: Gregory P. Smith [Google LLC] <greg@krypto.org>
Diffstat (limited to 'Lib/ssl.py')
-rw-r--r--Lib/ssl.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/Lib/ssl.py b/Lib/ssl.py
index cc685c2..f248e14 100644
--- a/Lib/ssl.py
+++ b/Lib/ssl.py
@@ -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):