Simple HTTP server supporting SSL secure communications

Category: Python - Miscellaneous

This recipe describes how to set up a simple HTTP server supporting SSL secure communications. It extends the SimpleHTTPServer standard module to support the SSL protocol. With this recipe, only the server is authenticated while the client remains unauthenticated (i.e. the server will not request a client certificate). Thus, the client (typically the browser) will be able to verify the server identity and secure its communications with the server.

This recipe requires you already know the basis of SSL and how to set up OpenSSL. This recipe is mostly derived from the examples provided with the pyOpenSSL package.

In order to apply this recipe, follow these few steps:


Install the OpenSSL package in order to generate key and certificate. Note: you probably already have this package installed if you are under Linux, or *BSD.
Install the pyOpenSSL package, it is an OpenSSL library binding. You'll need to import this module for accessing OpenSSL's components.
Generate a self-signed certificate compounded of a certificate and a private key for your server with the following command (it outputs them both in a single file named server.pem):
openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes
Assuming you saved this recipe in SimpleSecureHTTPServer.py, start the server (with the appropriate rights):
python SimpleSecureHTTPServer.py
Finally, browse to https://localhost, or https://localhost:port if your server listens a different port than 443. Date: 03 January, 2012


Https - OpenSSL - Ssl - Web

Homepage: http://code.activestate.com/recipes/442473-simple-http-server-supporting-ssl-secure-communica/?in=lang-python

Developer: Sebastien Martini

License: Python License

Operating System: Windows

Add a Comment

all are required fields

     
What do you think of this resource?

Select Your Rate:

Votes:0

 

Related Scripts Download

dhtmlxVault is a DHTML file upload component that helps to implement modern and feature-rich file uploading part of a web application.

developer Developer: Ivan Petrenko
license License: GNU General Public License (GPL)
operating systems Operating System: Cross-Platform


Many payment processors like PayPal, eBay, Authorize.

developer Developer: e-junkie
license License: Freeware
operating systems Operating System: Linux, Unix, Windows


Abyss web server is multi-platform compatible.

developer Developer: RF
license License: Freeware
operating systems Operating System: All


SSL is an internet security protocol.

developer Developer: scripts.franciscocharrua.com
license License: Freeware
operating systems Operating System: All


First, the scripts sends the GET query to read the website cookies (for session, etc.

developer Developer: snippets.dzone.com
license License: Freeware
operating systems Operating System: Windows, Linux


Ruby has different libraries that provide higher-level access to network protocols such as FTP, HTTP or HTTPS.

developer Developer: snippets.dzone.com
license License: Freeware
operating systems Operating System: Windows, Linux


Twilio is a telephony service that POSTs to a callback URL on your server and asks you what to do when it receives phone calls or SMSes to the numbers you rent from Twilio.

developer Developer: Jesse Davis
license License: Freeware
operating systems Operating System: Windows


This shared lock implementation supports timeouts so that an attempt to acquire a lock occasionally times out.

developer Developer: Dmitry Dvoinikov
license License: Python License
operating systems Operating System: Windows


Trivia is simple but powerful Python Template.

developer Developer: Petko Petkov
license License: Python License
operating systems Operating System: Windows