Skip to content

🧪 Silence pyOpenSSL deprecation warnings instead - #852

Merged
webknjaz merged 1 commit into
cherrypy:mainfrom
julianz-:fix/pyopenssl-filterwarnings
Oct 6, 2026
Merged

webknjaz merged 1 commit into
cherrypy:mainfrom
julianz-:fix/pyopenssl-filterwarnings

Conversation

@julianz-

@julianz- julianz- commented Oct 3, 2026 •

Copy link
Copy Markdown
Member

What kind of change does this PR introduce?

  • 🐞 bug fix
  • 🐣 feature
  • 📋 docs update
  • 📋 tests/coverage improvement
  • 📋 refactoring
  • 💥 other

What do these changes do?

pyOpenSSL 26.3.0+ raises DeprecationWarning for Context.set_passwd_cb, X509.get_issuer, and X509.get_subject — treated as hard errors here since warnings are configured to fail the test suite.

This is blocking the CI today. #808 (an automated pip-tools dependency bump) currently fails on Python 3.12 because of exactly this warning, and that single failure cascades via fail-fast into canceling every other job in its Tests matrix — making an otherwise-routine, unrelated maintenance PR look completely broken.

This PR adds filterwarnings entries for the exact messages instead of the real migration in #846, as a stopgap to unblock #808 now, while the long term fix proceeds separately.

Are there changes in behavior for the user?

No — this only changes the test suite's warning-filter configuration. It doesn't affect cheroot's runtime behavior for anyone using the library.

Is it a substantial burden for the maintainers to support this?

Minor, and temporary by design.

Related issue number

This is a temporary patch that can be removed once #846 or equivalent lands.

Checklist

  • I wrote descriptive pull request text above
  • The PR relates to only one subject with a clear title
    and description in grammatically correct, complete sentences
  • I think the code is well written
  • Unit tests for the changes exist
  • Integration tests for the changes exist (if applicable)
  • I used the same coding conventions as the rest of the project
  • The new code doesn't generate linter offenses
  • Project documentation (in docs/) and inline docstrings reflect the changes
  • My commits each have a descriptive title and a body explaining the why
    (see good commit messages)
  • I have added a change log entry
    (can be done once the PR number is known; alternatively, you can
    use a related issue number if one exists)
  • I'm planning to squash related commits together before final merge
  • I have read the contribution guide and the
    code of conduct

@pyba-chronographer pyba-chronographer Bot added the bot:chronographer:provided A mark meaning that a new change log entry is present within the patch. label Oct 3, 2026
@read-the-docs-community

read-the-docs-community Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Documentation build overview

📚 cheroot | 🛠️ Build #34917582 | 📁 Comparing 1f3d21e against latest (2aa0a25)

  🔍 Preview build  

2 files changed
± history/index.html
± pkg/cheroot.server/index.html

@codecov

codecov Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.20%. Comparing base (2aa0a25) to head (1f3d21e).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #852   +/-   ##
=======================================
  Coverage   78.20%   78.20%           
=======================================
  Files          41       41           
  Lines        4791     4791           
  Branches      548      548           
=======================================
  Hits         3747     3747           
  Misses        905      905           
  Partials      139      139           

@webknjaz webknjaz changed the title 🧪 Silence pyOpenSSL deprecation warnings instead of migrating off them 🧪 Silence pyOpenSSL deprecation warnings instead Oct 3, 2026
@@ -0,0 +1,13 @@
Silenced the ``DeprecationWarning``\ s that :pypi:`pyOpenSSL` 26.3.0+
raises for

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the library doesn't raise warnings as exceptions so don't make it sound like it does:

Suggested change
raises for
emits for

It only sends warnings through standard machinery and our filterwarnings=error in the pytest config is what elevates warnings to errors.
This is our doing, which also means this is not a bug and the change note should be in the contrib category, not bugfix.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's contrib, not bugfix.

@@ -0,0 +1,13 @@
Silenced the ``DeprecationWarning``\ s that :pypi:`pyOpenSSL` 26.3.0+

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Silenced the ``DeprecationWarning``\ s that :pypi:`pyOpenSSL` 26.3.0+
Silenced the :exc:`DeprecationWarning`\ s that :pypi:`pyOpenSSL` 26.3.0+

and
:external+pyopenssl:py:meth:`X509.get_subject <OpenSSL.crypto.X509.get_subject>`
-- treated as hard errors here since warnings are configured to fail
the test suite. A real migration away from these deprecated calls is

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This phrasing sounds awfully like an LLM output.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the note have to be this verbose? Try leaving the important points without going into too much noise.

pyOpenSSL 26.3.0+ emits DeprecationWarning for Context.set_passwd_cb,
X509.get_issuer, and X509.get_subject -- our own filterwarnings=error
config is what turns those into hard test failures, not pyOpenSSL
itself. Add filterwarnings entries for the exact messages instead of
the real migration tracked in cherrypy#846, as a lower-effort stopgap to
keep the suite green against newer pyOpenSSL releases.

Verified against a real pyOpenSSL 26.4.0 install (the lockfile-pinned
25.3.0 doesn't trigger these yet): the full suite genuinely fails
without the filters (30 failures) and passes clean with them (200
passed, 0 failures).
@julianz-
julianz- force-pushed the fix/pyopenssl-filterwarnings branch from 3ce0fbd to 1f3d21e Compare October 3, 2026 15:22
@webknjaz

webknjaz commented Oct 3, 2026

Copy link
Copy Markdown
Member

Comment thread pytest.ini
Comment on lines +69 to +71
ignore:Context.set_passwd_cb is deprecated. You should decrypt and load your private key yourself, with cryptography's key loading APIs, and then use Context.use_privatekey instead.:DeprecationWarning
ignore:X509.get_issuer is deprecated. You should use cryptography's X.509 APIs instead.:DeprecationWarning
ignore:X509.get_subject is deprecated. You should use cryptography's X.509 APIs instead.:DeprecationWarning

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a trailing :importable.module.path to scope them so they don't apply to everything but only allow this warning to be dismissed in that one single module?

@julianz- julianz- Oct 6, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried this but had issues with set_passwd_cb - test_openssl_adapter_with_false_key_password[too-long-password] fails when the ignore is scoped because this test uses pytest.warns to look for UserWarning about the password being too long but when it sees the deprecation warning it hands it back labeled with the module _py_warnings, so the scoped ignore doesn't match.

Maybe scope the other two but not set_passwd_cb? Otherwise I would have to modify the test I guess.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay then. It'd be too much for for little gain. It's probably worth looking into improving test layering, maybe. But not sure if it's a priority right now. So let's not block on it.

@webknjaz
webknjaz merged commit a6283c1 into cherrypy:main Oct 6, 2026
117 of 159 checks passed
@julianz-
julianz- deleted the fix/pyopenssl-filterwarnings branch October 6, 2026 18:36
julianz- added a commit to julianz-/cheroot that referenced this pull request Nov 4, 2026
The previous commit stops calling Context.set_passwd_cb, X509.get_issuer,
and X509.get_subject, so these three filterwarnings entries (added as a
stopgap in cherrypy#852) never match anything anymore.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided A mark meaning that a new change log entry is present within the patch.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants