Multiple Ports and SSL

View: New views
4 Messages — Rating Filter:   Alert me  

Multiple Ports and SSL

by janglin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I have been trying to get a dual server application up and running where one server serves HTTP and the other HTTPS using cherrypy 3.1.2.  I have read the other "Multiple Ports and SSL" thread here http://www.nabble.com/Multiple-ports-and-SSL-td19736800.html#a20764816.

I did try the changes discussed in that thread to the files _cpserver.py, _cpwsgi_server.py, and wsgiserver\__init_.py but it still did not work for me.   With those changes applied I get the following startup messages:
[01/Oct/2009:14:32:02] ENGINE Started monitor thread '_TimeoutMonitor'.
[01/Oct/2009:14:32:02] ENGINE Started monitor thread 'Autoreloader'.
[01/Oct/2009:14:32:03] ENGINE Serving on 0.0.0.0:8443
[01/Oct/2009:14:32:03] ENGINE Serving on 0.0.0.0:8080
[01/Oct/2009:14:32:03] ENGINE Bus STARTED

Yet when I navigate to http://localhost:8080 or https://localhost:8443 I get 101 errors (ERR_CONNECTION_RESET)

This is just with a small sample app:
import cherrypy
from cherrypy import _cpserver
import os.path

localDir = os.path.abspath(os.path.dirname(__file__))
CA = os.path.join(localDir, 'server.crt')
KEY = os.path.join(localDir, 'server.key')

def setup_app():
    class Root(object):
        @cherrypy.expose
        def index(self):
            return "Here is a page"

    cherrypy.tree.mount(Root())


if __name__ == '__main__':

    cherrypy.server2 = s2 = _cpserver.Server()
    s2.socket_host = '0.0.0.0'
    s2.socket_port = 8443
    s2.ssl_certificate = CA
    s2.ssl_private_key = KEY
    s2.subscribe()

    cherrypy.server.socket_host = '0.0.0.0'

    setup_app()

    cherrypy.engine.start()
    cherrypy.engine.block()

As a matter of fact, I can't even connect a single server application when I apply the changes discussed in the aforementioned thread ( I must have missed something, it seemed to work for them).

Eventually I wish to have pages served via HTTP and web services (WSGI Apps) served over HTTPS, but I can't get even a simple app working.

Can anyone provide suggestions?  

Re: Multiple Ports and SSL

by janglin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Using cherrypy 3.2 beta0 (from trunk) with the same example code from before.  I now get a working ssl server but a non-working http server.  When I navigate to http://localhost:8080, I get a 400 error:

"The client sent a plain HTTP request, but this server only speaks HTTPS on this port."

So internally cherrypy is using ssl on each server:port combination. If I navigate to either https://localhost:8080 or https://localhost:8443 I get the expected page over ssl.  Am I using cherrypy in an incorrect manner or is this a bug?


janglin wrote:
I have been trying to get a dual server application up and running where one server serves HTTP and the other HTTPS using cherrypy 3.1.2.  I have read the other "Multiple Ports and SSL" thread here http://www.nabble.com/Multiple-ports-and-SSL-td19736800.html#a20764816.

I did try the changes discussed in that thread to the files _cpserver.py, _cpwsgi_server.py, and wsgiserver\__init_.py but it still did not work for me.   With those changes applied I get the following startup messages:
[01/Oct/2009:14:32:02] ENGINE Started monitor thread '_TimeoutMonitor'.
[01/Oct/2009:14:32:02] ENGINE Started monitor thread 'Autoreloader'.
[01/Oct/2009:14:32:03] ENGINE Serving on 0.0.0.0:8443
[01/Oct/2009:14:32:03] ENGINE Serving on 0.0.0.0:8080
[01/Oct/2009:14:32:03] ENGINE Bus STARTED

Yet when I navigate to http://localhost:8080 or https://localhost:8443 I get 101 errors (ERR_CONNECTION_RESET)

This is just with a small sample app:
import cherrypy
from cherrypy import _cpserver
import os.path

localDir = os.path.abspath(os.path.dirname(__file__))
CA = os.path.join(localDir, 'server.crt')
KEY = os.path.join(localDir, 'server.key')

def setup_app():
    class Root(object):
        @cherrypy.expose
        def index(self):
            return "Here is a page"

    cherrypy.tree.mount(Root())


if __name__ == '__main__':

    cherrypy.server2 = s2 = _cpserver.Server()
    s2.socket_host = '0.0.0.0'
    s2.socket_port = 8443
    s2.ssl_certificate = CA
    s2.ssl_private_key = KEY
    s2.subscribe()

    cherrypy.server.socket_host = '0.0.0.0'

    setup_app()

    cherrypy.engine.start()
    cherrypy.engine.block()

As a matter of fact, I can't even connect a single server application when I apply the changes discussed in the aforementioned thread ( I must have missed something, it seemed to work for them).

Eventually I wish to have pages served via HTTP and web services (WSGI Apps) served over HTTPS, but I can't get even a simple app working.

Can anyone provide suggestions?  

Re: Multiple Ports and SSL

by Robert Brewer-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


janglin wrote:

> Using cherrypy 3.2 beta0 (from trunk) with the same example code
> from before. I now get a working ssl server but a non-working
> http server.  When I navigate to http://localhost:8080, I get
> a 400 error:
>
> "The client sent a plain HTTP request, but this server only speaks
> HTTPS on this port."
>
> So internally cherrypy is using ssl on each server:port combination.
> If I navigate to either https://localhost:8080 or
https://localhost:8443
> I get the expected page over ssl.  Am I using cherrypy in an incorrect
> manner or is this a bug?

A bug. Fixed in http://www.cherrypy.org/changeset/2536.

Incidentally, you should be able to use the new 'server.<name>.*'
attributes to do this more easily. See the 'scaffold' app in 3.2 for a
working example (just added):

    [global]
    # Uncomment this when you're done developing
    #environment: "production"

    server.socket_host: "0.0.0.0"
    server.socket_port: 8088

    # Uncomment the following lines to run on HTTPS at the same time
    #server.2.socket_host: "0.0.0.0"
    #server.2.socket_port: 8433
    #server.2.ssl_certificate: '../test/test.pem'
    #server.2.ssl_private_key: '../test/test.pem'

    tree.myapp: cherrypy.Application(scaffold.root, "/", "example.conf")


Robert Brewer
fumanchu@...


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users@...
To unsubscribe from this group, send email to cherrypy-users+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Multiple Ports and SSL

by janglin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks, everything works now as expected with latest trunk, 2548 is the one I got.

Robert Brewer-4 wrote:
janglin wrote:
> Using cherrypy 3.2 beta0 (from trunk) with the same example code
> from before. I now get a working ssl server but a non-working
> http server.  When I navigate to http://localhost:8080, I get
> a 400 error:
>
> "The client sent a plain HTTP request, but this server only speaks
> HTTPS on this port."
>
> So internally cherrypy is using ssl on each server:port combination.
> If I navigate to either https://localhost:8080 or
https://localhost:8443
> I get the expected page over ssl.  Am I using cherrypy in an incorrect
> manner or is this a bug?

A bug. Fixed in http://www.cherrypy.org/changeset/2536.

Incidentally, you should be able to use the new 'server.<name>.*'
attributes to do this more easily. See the 'scaffold' app in 3.2 for a
working example (just added):

    [global]
    # Uncomment this when you're done developing
    #environment: "production"

    server.socket_host: "0.0.0.0"
    server.socket_port: 8088

    # Uncomment the following lines to run on HTTPS at the same time
    #server.2.socket_host: "0.0.0.0"
    #server.2.socket_port: 8433
    #server.2.ssl_certificate: '../test/test.pem'
    #server.2.ssl_private_key: '../test/test.pem'

    tree.myapp: cherrypy.Application(scaffold.root, "/", "example.conf")


Robert Brewer
fumanchu@aminus.org


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users@googlegroups.com
To unsubscribe from this group, send email to cherrypy-users+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---