Created
October 22, 2018 16:16
-
-
Save mateusza/3429a3946a87876e456e81d4ce7c1591 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
n=razi91 | |
openssl genrsa -out $n.key | |
openssl rsa -pubout -in $n.key -out $n.pub | |
openssl req -new -sha256 -key $n.key -subj '/CN=127.0.0.1/' -out $n.csr | |
openssl x509 -req -in $n.csr -signkey $n.key -out $n.crt -days 30 |
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 python | |
import http.server, socketserver | |
import socket, ssl | |
n='razi91' | |
KLUCZ = '%s.key' % n | |
CERTYFIKAT = '%s.crt' % n | |
PORT = 8443 | |
HOST = socket.gethostname() | |
RH = http.server.SimpleHTTPRequestHandler | |
https = socketserver.TCPServer( | |
("0.0.0.0", PORT), RH | |
) | |
https.socket = ssl.wrap_socket( | |
https.socket, | |
keyfile = KLUCZ, | |
certfile= CERTYFIKAT | |
) | |
print( "Serwer HTTPS", HOST, ":", PORT ) | |
https.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 python | |
import requests | |
n='razi91' | |
URL="https://127.0.0.1:8443/test.txt" | |
req = requests.get( URL, verify='razi91.crt' ) | |
print( req.text ) |
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 python | |
import requests | |
from requests.packages.urllib3.exceptions import SubjectAltNameWarning | |
requests.packages.urllib3.disable_warnings(SubjectAltNameWarning) | |
n='razi91' | |
URL="https://127.0.0.1:8443/test.txt" | |
req = requests.get( URL, verify=('%s.crt' % n) ) | |
print( req.text ) |
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
No i dziala. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment