{"id":152,"date":"2011-07-20T21:15:36","date_gmt":"2011-07-21T04:15:36","guid":{"rendered":"https:\/\/www.zacwitte.com\/?p=152"},"modified":"2011-07-20T21:15:36","modified_gmt":"2011-07-21T04:15:36","slug":"using-ssl-https-with-cherrypy-3-2-0-example","status":"publish","type":"post","link":"https:\/\/zacwitte.com\/?p=152","title":{"rendered":"Using SSL HTTPS with cherrypy 3.2.0 Example"},"content":{"rendered":"<p>It took me more time than it should have to piece together the right bits of current information for using SSL with cherrypy. Here&#8217;s a fully working example of cherrypy 3.2.0 serving up HTTPS requests.<\/p>\n<p>Quick notes &#8211; if you haven&#8217;t tried <a href=\"http:\/\/cherrypy.org\">cherrypy<\/a>, do it. It&#8217;s awesome in its simplicity. Also, I got my SSL cert from godaddy, which was the cheapest I found. This particular cert uses a certificate chain, so when all is said and done we have my_cert.crt, my_cert.key, and\u00a0gd_bundle.crt. <\/p>\n<p>ssl_server.py:<\/p>\n<pre>import cherrypy\n\nclass RootServer:\n    @cherrypy.expose\n    def index(self, **keywords):\n        return \"it works!\"\n\nif __name__ == '__main__':\n    server_config={\n        'server.socket_host': '0.0.0.0',\n        'server.socket_port':443,\n\n        'server.ssl_module':'pyopenssl',\n        'server.ssl_certificate':'\/home\/ubuntu\/my_cert.crt',\n        'server.ssl_private_key':'\/home\/ubuntu\/my_cert.key',\n        'server.ssl_certificate_chain':'\/home\/ubuntu\/gd_bundle.crt'\n    }\n\n    cherrypy.config.update(server_config)\n    cherrypy.quickstart(RootServer())<\/pre>\n<p>Launch the server like:<\/p>\n<pre>sudo python ssl_server.py<\/pre>\n<p>You need to use sudo because it runs on port 443.  You should be asked to &#8220;Enter PEM pass phrase&#8221; that you set when generating your key.<\/p>\n<p><strong>Update:<\/strong> In a <a href=\"https:\/\/www.zacwitte.com\/running-cherrypy-on-multiple-ports-example\">follow-up post<\/a> I show how you run an HTTPS server (port 443) and an HTTP server (port 80) at the same time.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It took me more time than it should have to piece together the right bits of current information for using SSL with cherrypy. Here&#8217;s a fully working example of cherrypy 3.2.0 serving up HTTPS requests. Quick notes &#8211; if you haven&#8217;t tried cherrypy, do it. It&#8217;s awesome in its simplicity. Also, I got my SSL [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-152","post","type-post","status-publish","format-standard","hentry","category-tech"],"_links":{"self":[{"href":"https:\/\/zacwitte.com\/index.php?rest_route=\/wp\/v2\/posts\/152","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zacwitte.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zacwitte.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zacwitte.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zacwitte.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=152"}],"version-history":[{"count":0,"href":"https:\/\/zacwitte.com\/index.php?rest_route=\/wp\/v2\/posts\/152\/revisions"}],"wp:attachment":[{"href":"https:\/\/zacwitte.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=152"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zacwitte.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=152"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zacwitte.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=152"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}