giampaolo / pyftpdlib

Extremely fast and scalable Python FTP server library
MIT License
1.65k stars 266 forks source link

Breaks with PyOpenSSL version 22.1.0 #578

Closed oz123 closed 1 year ago

oz123 commented 1 year ago

In pyftpdlib.handlers.TLS_FTPHandler'

     @classmethod
      def get_ssl_context(cls):
          if cls.ssl_context is None:
              if cls.certfile is None:
                  raise ValueError("at least certfile must be specified")
              cls.ssl_context = SSL.Context(cls.ssl_protocol)
  >           if cls.ssl_protocol != SSL.SSLv2_METHOD:
  E           AttributeError: module 'OpenSSL.SSL' has no attribute 'SSLv2_METHOD'
padraic-padraic commented 1 year ago

Running under Python 3.10, I got this additional information:

AttributeError: module 'OpenSSL.SSL' has no attribute 'SSLv2_METHOD'. Did you mean: 'SSLv23_METHOD'?
giampaolo commented 1 year ago

With OpenSSL version 22.0.0 everything is fine:

~/svn/pyftpdlib {master}$ python3
Python 3.10.6 (main, Aug 10 2022, 11:40:04) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
[ loading '/home/giampaolo/.pythonstart' ]
>>> from OpenSSL import SSL
>>> SSL.SSLv2_METHOD
1
>>> 
>>>>>> import OpenSSL
>>> OpenSSL.__version__
'22.0.0'
>>> 

The problem appeared with 22.1.0:

>>> import OpenSSL
>>> OpenSSL.__version__
'22.1.0'
>>> from OpenSSL import SSL
>>> SSL.SSLv2_METHOD
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'OpenSSL.SSL' has no attribute 'SSLv2_METHOD'
>>> 
giampaolo commented 1 year ago

Fixed. I just release a new pyftpdlib version on PYPI.