Reputation: 2931
Getting following error when running python script for web
Traceback (most recent call last):
File "SampleWSTest.py", line 10, in <module>
from web.wsgiserver.ssl_builtin import BuiltinSSLAdapter
File "C:\Python27\lib\site-packages\web\wsgiserver\ssl_builtin.py", line 14, in <module>
from cherrypy import wsgiserver
ImportError: cannot import name wsgiserver
Running on python 2.7.15
import web
import sys
import argparse
import traceback
from web.wsgiserver import CherryPyWSGIServer
from web.wsgiserver.ssl_builtin import BuiltinSSLAdapter
from OpenSSL import SSL
class Healthcheck:
def GET(self):
return 'Yassssssssss !!!!!'
URLS = ('/svc/healthcheck', 'Healthcheck')
CherryPyWSGIServer.ssl_certificate = 'alice.crt'
CherryPyWSGIServer.ssl_private_key = 'alice.key'
if __name__ == '__main__':
CherryPyWSGIServer.ssl_adapter = BuiltinSSLAdapter(CherryPyWSGIServer.ssl_certificate, CherryPyWSGIServer.ssl_private_key)
CherryPyWSGIServer.ssl_adapter.context = SSL.Context(SSL.SSLv23_METHOD)
CherryPyWSGIServer.ssl_adapter.context.set_options(SSL.OP_NO_SSLv3)
CherryPyWSGIServer.ssl_adapter.context.use_certificate_file(CherryPyWSGIServer.ssl_certificate)
CherryPyWSGIServer.ssl_adapter.context.use_privatekey_file(CherryPyWSGIServer.ssl_private_key)
app = web.application(URLS, globals())
app.run()
This started failing after we had to disable ssl 2
and ssl 3
so had to add ssl_adapter
but BuiltinSSLAdapter fails with the import.
If any other alternatives please suggest. Basically want to disable ssl 2
and ssl 3
previously we didnt have from web.wsgiserver.ssl_builtin import BuiltinSSLAdapter
from OpenSSL import SSL
Upvotes: 2
Views: 3880
Reputation: 1675
CherryPy moved wsgiserver to cheroot in 2017.
http://docs.cherrypy.dev/en/latest/history.html#v9-0-0
So now you need to import it like this:
from cheroot.wsgi import Server as CherryPyWSGIServer
or rename it throughout.
Upvotes: 5