In conjunction with the openssl scripts… a little bit of python code to fire up an ssl server… lots of them out there, this one is mine.

#!/usr/bin/env python

# fire up an HTTPS/ssl web server in the PWD (defaults to localhost:8081)
# optional - give a file name to serve up, like "$0 foofile.html"
# If you use this option it'll wait a few seconds and then try to open it
# using the
# Keyfiles are in variables... defaulting to /tmp + server.crt, server.key, and ca.crt.

import BaseHTTPServer, SimpleHTTPServer, os, sys, ssl

# server=''
host         = ''
port         = 8081

# cert files
certfile     = "/tmp/server.crt"
keyfile      = "/tmp/server.key"
ca_certz     = "/tmp/ca.crt"

# command to open up a URL & the server
fetch_url    = "open"
server       = "https://%s:%s/" % (host, port)

# actual web server stuff
httpd        = BaseHTTPServer.HTTPServer((host, port), SimpleHTTPServer.SimpleHTTPRequestHandler)
httpd.socket = ssl.wrap_socket (httpd.socket, ca_certs=ca_certz, certfile=certfile, keyfile=keyfile, server_side=True)

    # fire up a browser to fetch the url, but sleep a few seconds to give the server a chance to get going
    if len(sys.argv) > 1:
        shell_string = "(sleep 3; %s %s/%s) &" % (fetch_url, server, sys.argv[1])
            print("'%s' not supported on this OS ('%s' works on mac)" % (fetch_url, "open"))

    print "Serving SSL webz @ %s" % server

except Exception, err:
    print "couldn't start web server: %s" % err

Sorry, the comment form is closed at this time.

© 2012 trouble Suffusion theme by Sayontan Sinha