Created
December 31, 2017 23:00
-
-
Save vndmtrx/928483b9c70945133aaad34def647362 to your computer and use it in GitHub Desktop.
Servidor HTTPS em Python2/3 com TLS ativado, para fins de desenvolvimento
This file contains 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
#!/usr/bin/env bash | |
openssl req -new -x509 -keyout certificado.pem -out certificado.pem -days 365 -nodes |
This file contains 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
#!/usr/bin/env python2 | |
import BaseHTTPServer, SimpleHTTPServer | |
import ssl | |
endereco_servidor = ('localhost', 4567) | |
httpd = BaseHTTPServer.HTTPServer(endereco_servidor, SimpleHTTPServer.SimpleHTTPRequestHandler) | |
httpd.socket = ssl.wrap_socket(httpd.socket, | |
server_side=True, | |
certfile='./certificado.pem', | |
ssl_version=ssl.PROTOCOL_TLSv1_2) | |
httpd.serve_forever() |
This file contains 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
#!/usr/bin/env python3 | |
import http.server, ssl | |
endereco_servidor = ('localhost', 4567) | |
httpd = http.server.HTTPServer(endereco_servidor, http.server.SimpleHTTPRequestHandler) | |
httpd.socket = ssl.wrap_socket(httpd.socket, | |
server_side=True, | |
certfile='./certificado.pem', | |
ssl_version=ssl.PROTOCOL_TLSv1_2) | |
httpd.serve_forever() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment