Skip to content

SSLSocket.get_verified_chain() and get_unverified_chain() raise AttributeError after the TLS layer is torn down #155327

Description

@tonghuaroot

Bug report

SSLSocket.get_verified_chain() and SSLSocket.get_unverified_chain() raise
AttributeError when called after the socket's TLS layer is torn down (for
example after unwrap()), while every other query method (cipher(),
version(), group(), ...) returns a value:

>>> s.unwrap()
>>> s.get_verified_chain()
Traceback (most recent call last):
  ...
AttributeError: 'NoneType' object has no attribute 'get_verified_chain'

The two methods access self._sslobj without the _checkClosed() /
if self._sslobj is None guard the sibling methods use. They were added in
gh-109113 (3.13), so 3.13 and later are affected.

CPython versions tested on:

3.16 (main)

Operating systems tested on:

Linux, macOS

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytopic-SSLtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions