Re: [cherrypy-users] Simple SSL example using just the standard library?

611 views
Skip to first unread message

Sylvain Hellegouarch

unread,
Oct 20, 2012, 2:50:45 AM10/20/12
to cherryp...@googlegroups.com
Hi Amy,

On Sat, Oct 20, 2012 at 12:06 AM, Amy <amydur...@hotmail.com> wrote:
Hi!

Does anyone have a simple 'Hello World' demo that they could share of a cherrypy app with both http and https (using python's native SSL instead of pyopenssl)?

I'm a little confused with how this documentation:


should be applied to the multiple http server example on this page:


I've been trying to get this to work for a few days now with no luck. I must be missing something obvious.. :(




Could you have a look at https://bitbucket.org/Lawouach/cherrypy-recipes/src/c899e1b914171d3c3d9f3b80bb22f2e9e41992b6/deployment/tls and let us know if it helps?

--
- Sylvain
http://www.defuze.org
http://twitter.com/lawouach

Amy

unread,
Oct 20, 2012, 7:19:41 AM10/20/12
to cherryp...@googlegroups.com
Wow! Great link - I'll have to check out some of the other recipes after I get this one working.

- ssl_and_plain_servers.py
- single_ssl_server.py

both exited prematurely with the same error:

"File "c:\python27\lib\site-packages\cherrypy\wsgiserver\ssl_pyopenssl.py", line 173, in __init__ 
raise ImportError("You must install pyOpenSSL to use HTTPS.")
ImportError: You must install pyOpenSSL to use HTTPS."

(This is very similar to the error that I get when tried various examples on the web..)

The last one (wsgi_ssl_server.py) does work but it looks like something's not right; I didn't get any logging information (like the others) and when I sent the quit command it displayed:

"File "c:\python27\lib\site-packages\cherrypy\wsgiserver\wsgiserver2.py", line 1887, in tick
s, addr = self.socket.accept()
KeyboardInterrupt"

..and didn't return me to the command prompt (it looks like the window hung as it had to be forcibly closed)

I'll try to merge wsgi_ssl_server.py and ssl_and_plain_servers.py but it looks like they are accomplishing the same task very differently.

Question - why does Cherrypy default to pyOpenSSL (which people may not have installed) instead of the ssl module in the python standard library (which they almost certainly have installed)? Is the native ssl module lacking something that pyOpenSSL has? (Is it not a best practice to use the native ssl module?)

Thanks again for the link! I will try to get it working in the meantime.

Tim Roberts

unread,
Oct 22, 2012, 12:57:30 PM10/22/12
to cherryp...@googlegroups.com
Amy wrote:
>
> Question - why does Cherrypy default to pyOpenSSL (which people may
> not have installed) instead of the ssl module in the python standard
> library (which they almost certainly have installed)? Is the native
> ssl module lacking something that pyOpenSSL has? (Is it not a best
> practice to use the native ssl module?)

CherryPy has been around for a very long time -- long before the ssl
module was added to the standard library. Inertia explains the rest.
If it ain't broke, don't fix it.

If you are so inclined, I am sure patches would be welcomed.

--
Tim Roberts, ti...@probo.com
Providenza & Boekelheide, Inc.

Reply all
Reply to author
Forward
0 new messages