Skip to content

Replace deprecated ssl.wrap_socket with SSLContext.wrap_socket for Py…#79

Open
carlowahlstedt wants to merge 1 commit into
mattdodge:masterfrom
carlowahlstedt:patch-1
Open

Replace deprecated ssl.wrap_socket with SSLContext.wrap_socket for Py…#79
carlowahlstedt wants to merge 1 commit into
mattdodge:masterfrom
carlowahlstedt:patch-1

Conversation

@carlowahlstedt
Copy link
Copy Markdown

Python 3.12 removes functional support for ssl.wrap_socket, which causes the CLI login flow to fail with:

AttributeError: module 'ssl' has no attribute 'wrap_socket'

This PR updates the login server code to use the modern SSLContext.wrap_socket API, maintaining compatibility with Python 3.12+ while preserving behavior for earlier versions.

🔧 Changes
• Replaced ssl.wrap_socket with an SSLContext instance using ssl.PROTOCOL_TLS_SERVER.
• Loads certificate and key as before.
• Wraps the server socket with context.wrap_socket(..., server_side=True).

Copy link
Copy Markdown
Owner

@mattdodge mattdodge left a comment

Choose a reason for hiding this comment

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

appreciate you looking into this! DIdn't realize this was failing on 3.12. A little cleanup needed I think but lmk when done and I'll take another look. I can also try to track this down in more detail later this week

Comment thread yahoofantasy/cli/login.py
click.echo("Using localhost SSL certificate (HTTPS)")
server.socket = ssl.wrap_socket(
context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
context.load_cert_chain(certfile=certfile, keyfile=keyfile)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I think certfile needs to be defined somewhere first

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

You mean AI got it wrong?! lol. If you find time, go for it. I've been too covered over to even continue on the side pet project I was working on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants