sauth icon indicating copy to clipboard operation
sauth copied to clipboard

error using https

Open mrmte opened this issue 2 years ago • 1 comments

error using https

Traceback (most recent call last): File "/Library/ManagedFrameworks/Python/Python3.framework/Versions/3.10/bin/sauth", line 8, in sys.exit(main()) File "/Library/ManagedFrameworks/Python/Python3.framework/Versions/3.10/lib/python3.10/site-packages/click/core.py", line 1130, in call return self.main(*args, **kwargs) File "/Library/ManagedFrameworks/Python/Python3.framework/Versions/3.10/lib/python3.10/site-packages/click/core.py", line 1055, in main rv = self.invoke(ctx) File "/Library/ManagedFrameworks/Python/Python3.framework/Versions/3.10/lib/python3.10/site-packages/click/core.py", line 1404, in invoke return ctx.invoke(self.callback, **ctx.params) File "/Library/ManagedFrameworks/Python/Python3.framework/Versions/3.10/lib/python3.10/site-packages/click/core.py", line 760, in invoke return __callback(*args, **kwargs) File "/Library/ManagedFrameworks/Python/Python3.framework/Versions/3.10/lib/python3.10/site-packages/sauth.py", line 137, in main serve_http(ip=ip, port=port, https=https, start_dir=dir, use_threads=use_threads) File "/Library/ManagedFrameworks/Python/Python3.framework/Versions/3.10/lib/python3.10/site-packages/sauth.py", line 83, in serve_http httpd.socket = ssl.wrap_socket(httpd.socket, keyfile=KEY_FILE, certfile=CERT_FILE, server_side=True) NameError: name 'httpd' is not defined. Did you mean: 'https'?

mrmte avatar Jul 05 '23 10:07 mrmte

Found the gist that this is probably copy-pasted from: https://gist.github.com/dergachev/7028596

Fixed w/ this patch:

M sauth/sauth.py
@@ -135,14 +135,15 @@ def serve_http(
 ):
     """setting up server"""

-    if https:
-        httpd.socket = ssl.wrap_socket(httpd.socket, keyfile=KEY_FILE, certfile=CERT_FILE, server_side=True)
-
     if start_dir:
         print("Changing dir to {cd}".format(cd=start_dir))
         os.chdir(start_dir)

     server = HTTPServer((ip, port), SimpleHTTPAuthHandler)
+
+    if https:
+        server.socket = ssl.wrap_socket(server.socket, keyfile=KEY_FILE, certfile=CERT_FILE, server_side=True)
+
     print(
         'Serving "{}" directory on {}://{}:{}'.format(
             os.getcwd(),

mattpcaswell avatar Jan 21 '25 21:01 mattpcaswell