Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
LeoBeb opened this issue Nov 16, 2024 · 0 comments
Open

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

LeoBeb opened this issue Nov 16, 2024 · 0 comments

Comments

@LeoBeb
Copy link

LeoBeb commented Nov 16, 2024

When a client tries to connect to the server using TLS, the following error occurs:

Traceback (most recent call last):
  File "/usr/local/bin/electrum-personal-server", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/electrumpersonalserver/server/common.py", line 494, in main
    run_electrum_server(rpc, txmonitor, config)
  File "/usr/local/lib/python3.12/dist-packages/electrumpersonalserver/server/common.py", line 147, in run_electrum_server
    sock = ssl.wrap_socket(sock, server_side=True,
           ^^^^^^^^^^^^^^^
AttributeError: module 'ssl' has no attribute 'wrap_socket'

This is because the wrap_socket() function was deprecated after Python 3.7.
I was able to fix this by replacing lines 147-149:

                sock = ssl.wrap_socket(sock, server_side=True,
                    certfile=certfile, keyfile=keyfile,
                    ssl_version=ssl.PROTOCOL_SSLv23)

With the following:

                context = ssl.SSLContext(ssl.PROTOCOL_TLS)
                context.load_cert_chain(certfile=certfile, keyfile=keyfile)
                sock = context.wrap_socket(sock, server_side=True)

After that I was able to successfully connect with my Electrum wallet.

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

No branches or pull requests

1 participant