teddziuba / django-sslserver

A SSL-enabled development server for Django
MIT License
737 stars 108 forks source link

Python 2.7 and PROTOCOL_TLSv1_2 #63

Open cwurld opened 7 years ago

cwurld commented 7 years ago

The Python 2.7 ssl module does not have a ssl.PROTOCOL_TLSv1_2. This causes django-sslserver version 0.20 to fail. This error goes away when I revert to version 0.19

johnthagen commented 7 years ago

What version of 2.7? 2.7.9 (released three years ago) should have this.

https://docs.python.org/2/library/ssl.html#ssl.PROTOCOL_TLSv1_2

cwurld commented 7 years ago

2.7.6 - I guess I should update it.

badcrc commented 7 years ago

I'm having the same problem on macos sierra with python 2.7.10

AttributeError: 'module' object has no attribute 'PROTOCOL_TLSv1_2'
✗ python                              
Python 2.7.10 (default, Feb  7 2017, 00:08:15) 
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 

0.19 works fine.

mcescalante commented 6 years ago

I'm running into this problem with 2.7.14 and it looks to me like it's because PROTOCOL_TLSv1_2 is deprecated as of 2.7.13: https://docs.python.org/2/library/ssl.html#ssl.PROTOCOL_TLSv1_2

You can see in a IDLE session that my SSL configuration is working normally and the suggested replacement works fine, but PROTOCOL_TLSv1_2 can't be imported as it's deprecated:

Python 2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 12:01:12) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
>>> ssl.PROTOCOL_TLSv1_2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'PROTOCOL_TLSv1_2'
>>> ssl.OP_NO_SSLv3
33554432
johnthagen commented 6 years ago

but PROTOCOL_TLSv1_2 can't be imported as it's deprecated:

That's strange as "deprecated" just means "you shouldn't use this any more, it could be removed in the future" not, "this is gone."

That sounds like a Python bug report that either the implementation or docs need to be updated.

mcescalante commented 6 years ago

Yup you are right! This python installation had issues with TLS 1.2 and everything is working after recompiling python with the proper flags. Thank you for the helpful tool!

johnthagen commented 6 years ago

Great, just watch out for #64, my server will freeze when using django-sslserver if too many concurrent requests happen at once.