teddziuba / django-sslserver

A SSL-enabled development server for Django
MIT License
738 stars 109 forks source link

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

Open FlorianFey opened 2 months ago

FlorianFey commented 2 months ago

Hi guys,

I get this error when I run the server with both if these commands:

python manage.py runsslserver  --certificate localhost.pem  --key localhost-key.pem   
python manage.py runsslserver

The certificate is available.

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

I found a issue for this here that it should ne fixe, but it's still not working.

I am using Python 3.12.1.

Any solution for that?

Thx! Flo

ahmedsafadii commented 1 month ago

for now you can do the following

python3.12/site-packages/sslserver/management/commands/runsslserver.py

replace

self.socket = ssl.wrap_socket(self.socket, certfile=certificate, ...)

with

context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER) context.load_cert_chain(certfile=certificate, keyfile=key) self.socket = context.wrap_socket(self.socket, server_side=True)