Web.py - SSL签名

来源:互联网 发布:js方法中引入md5 编辑:程序博客网 时间:2024/06/11 16:07


实例代码:

http://webpy.org/cookbook/ssl

 

import web

from web.wsgiserver import CherryPyWSGIServer

 

CherryPyWSGIServer.ssl_certificate = "cacert.pem"

CherryPyWSGIServer.ssl_private_key = "prvtkey.pem"

 

urls = ("/.*", "hello")

app = web.application(urls, globals())

 

class hello:

    def GET(self):

        return 'Hello, world!'

 

if __name__ == "__main__":

    app.run()

代码说明:

安装pip install cherrypy

测试之前必须要先要用openssl 生成 私钥和公钥。

openssl genrsa -out prvtkey.pem 1024/2038

openssl req -new -x509 -key prvtkey.pem -out cacert.pem -days 1095

如果你再次生成另一个私钥,并赋值给代码,那么客户端将无法打开任何网站。

 

 

0 0