File tree Expand file tree Collapse file tree 4 files changed +51
-0
lines changed Expand file tree Collapse file tree 4 files changed +51
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Python3-SimpleHTTPServer-with-SSL
2
+
3
+ ## Usage
4
+ 1 . Git clone https://github.com/noobpk/Python3-SimpleHTTPServer-with-SSL.git
5
+ 2 . cd Python3-SimpleHTTPServer-withSSL/
6
+ 3 . Generate your certificate :
7
+ 1. `chmod +x generate-cert-selfsign.sh`
8
+ 2. `./generate-cert-selfsign.sh`
9
+ 4 . Add your path of file ` cert.pem ` to ` server.py `
10
+ 3 . Start server: ` python3 server.py `
11
+
12
+ ## Configure browsers to allow your certificate
13
+
14
+ ### Google Chrome
15
+ Access : ` chrome://flags/#allow-insecure-localhost ` and click ` Enable `
16
+ ### Firefox
17
+ Access: ` about:config ` then search ` security.enterprise_roots.enabled ` and click ` True `
18
+
19
+
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ # generate your certificate self-signed using on local
3
+ openssl req -new -x509 -sha256 -nodes -newkey rsa:2048 -days 365 -keyout cert.pem -out cert.pem
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html >
3
+ < head >
4
+ < title > Simple HTTP Server with SSL</ title >
5
+ </ head >
6
+ < body >
7
+ < h1 > Wellcome to my server!!</ h1 >
8
+ </ body >
9
+ </ html >
Original file line number Diff line number Diff line change
1
+ #!/bin/python3.8
2
+ #server.py
3
+ from http .server import HTTPServer , SimpleHTTPRequestHandler , HTTPStatus
4
+ import socketserver
5
+ import ssl
6
+
7
+ IP = '127.0.0.1'
8
+ PORT = 9090
9
+
10
+ #Start server without ssl
11
+ # httpd = socketserver.TCPServer((IP, PORT), SimpleHTTPRequestHandler)
12
+
13
+ #Start server with ssl
14
+ httpd = HTTPServer ((IP , PORT ), SimpleHTTPRequestHandler )
15
+ httpd .socket = ssl .wrap_socket (
16
+ httpd .socket , server_side = True ,
17
+ certfile = '/path/to/cert.pem' )
18
+
19
+ print ("Server start at: https://{}:{}" .format (IP , PORT ))
20
+ httpd .serve_forever ()
You can’t perform that action at this time.
0 commit comments