python / python/cpython

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

Open
#155,327 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

stdlib topic-SSL type-bug
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

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
  • gh-155328

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with SSLSocket.get_verified_chain() and get_unverified_chain(), then compare their handling of self._sslobj with sibling query methods after unwrap(). Done means both methods no longer raise AttributeError when the TLS layer is torn down and their behavior matches the other query methods in that state.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
networking, security
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.