Last active
January 26, 2018 09:43
-
-
Save manuthu/b6e3306058386bccc66aff40646568f0 to your computer and use it in GitHub Desktop.
Simple Python SSL Server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Generate a server.key and server.cert. | |
>> mike:tmp$ openssl req -nodes -new -x509 -keyout server.key -out server.cert | |
Combine the generated keys. | |
>> mike:tmp$ cat server.key server.cert > server.pem | |
Now run the script | |
""" | |
import BaseHTTPServer, SimpleHTTPServer | |
import ssl | |
certfile = './server.pem' | |
host = '0.0.0.0' | |
port = 9000 | |
httpd = BaseHTTPServer.HTTPServer((host, port), SimpleHTTPServer.SimpleHTTPRequestHandler) | |
httpd.socket = ssl.wrap_socket (httpd.socket, certfile=certfile, server_side=True) | |
print 'Accepting ssl connection Host:%s Port:%s ' % (host, port) | |
httpd.serve_forever() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To create an ssl server: