Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Review fixes.
  • Loading branch information
matiuszka committed Sep 11, 2023
commit 4a51db29416e7a5f09fa5394280bc7b20c1c8c56
6 changes: 2 additions & 4 deletions Doc/library/ssl.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1215,16 +1215,14 @@ SSL sockets also have the following additional methods and attributes:
.. method:: SSLSocket.get_verified_chain()
Comment thread
matiuszka marked this conversation as resolved.

Returns verified certificate chain provided by the other
end of the SSL channel as a list of ``_ssl.Certificate``.
Return ``None`` if no certificates were provided.
end of the SSL channel as a list of DER-encoded bytes.

.. versionadded:: 3.13

.. method:: SSLSocket.get_unverified_chain()

Returns unverified certificate chain provided by the other
Comment thread
gpshead marked this conversation as resolved.
Outdated
end of the SSL channel as a list of ``_ssl.Certificate``.
Return ``None`` if no certificates were provided.
end of the SSL channel as a list of DER-encoded bytes.

.. versionadded:: 3.13

Expand Down
20 changes: 14 additions & 6 deletions Lib/ssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -878,17 +878,25 @@ def getpeercert(self, binary_form=False):

def get_verified_chain(self):
"""Returns verified certificate chain provided by the other
end of the SSL channel as a list of ``_ssl.Certificate``.
Return ``None`` if no certificates were provided.
end of the SSL channel as a list of DER-encoded bytes.
"""
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]

def get_unverified_chain(self):
"""Returns unverified certificate chain provided by the other
end of the SSL channel as a list of ``_ssl.Certificate``.
Return ``None`` if no certificates were provided.
end of the SSL channel as a list of DER-encoded bytes.
"""
return self._sslobj.get_unverified_chain()
chain = self._sslobj.get_verified_chain()
Comment thread
matiuszka marked this conversation as resolved.
Outdated

if chain is None:
return []

return [cert.public_bytes(_ssl.ENCODING_DER) for cert in chain]

def selected_npn_protocol(self):
"""Return the currently selected NPN protocol as a string, or ``None``
Expand Down