hello,
I would like to use the ssl with integrated webpy server. So I
followed the following tutorial :
http://webpy.org/cookbook/ssl
import web
from web.wsgiserver import CherryPyWSGIServer
CherryPyWSGIServer.ssl_certificate = "path/to/ssl_certificate"
CherryPyWSGIServer.ssl_private_key = "path/to/ssl_private_key"
urls = ("/.*", "hello")
app = web.application(urls, globals())
class hello:
def GET(self):
return 'Hello, world!'
if __name__ == "__main__":
app.run()
I do not know exactly where are the paths of the certificate and
private key :
path/to/ssl_certificate
path/to/ssl_private_key
I created an SSL certificate using the following commands:
sudo apt-get install openssl
cd /etc/ssl
sudo openssl genrsa -out server.key 1024
sudo openssl req -new -key server.key -out server.csr
sudo openssl x509 -req -days 365 -in server.csr -signkey server.key -
out server.crt
Then I assumed that the paths were as follows: /etc/ssl/certs and /etc/
ssl/private.
When I start the server with the command "python code.py" I have the
following error :
http://0.0.0.0:8080/
Traceback (most recent call last):
File "code.py", line 80, in <module>
app.run()
File "/usr/local/lib/python2.6/dist-packages/web/application.py",
line 316, in run
return wsgi.runwsgi(self.wsgifunc(*middleware))
File "/usr/local/lib/python2.6/dist-packages/web/wsgi.py", line 54,
in runwsgi
return httpserver.runsimple(func, validip(listget(sys.argv, 1,
'')))
File "/usr/local/lib/python2.6/dist-packages/web/httpserver.py",
line 146, in runsimple
server.start()
File "/usr/local/lib/python2.6/dist-packages/web/wsgiserver/
__init__.py", line 1588, in start
self.bind(af, socktype, proto)
File "/usr/local/lib/python2.6/dist-packages/web/wsgiserver/
__init__.py", line 1628, in bind
ctx.use_privatekey_file(self.ssl_private_key)
OpenSSL.SSL.Error: [('PEM routines', 'PEM_read_bio', 'no start line'),
('SSL routines', 'SSL_CTX_use_PrivateKey_file', 'PEM lib')]
One of you can tell me if my approach is correct?