Browse Source

wsclient: add --no-ssl-verify

boyska 2 years ago
parent
commit
00e238384b
1 changed files with 13 additions and 1 deletions
  1. 13 1
      utils/wsclient.py

+ 13 - 1
utils/wsclient.py

@@ -1,5 +1,6 @@
 #!/usr/bin/python3 -u
 import argparse
+import ssl
 
 import websocket
 
@@ -7,6 +8,14 @@ import websocket
 def get_parser():
     p = argparse.ArgumentParser()
     p.add_argument(
+        "-k",
+        "--no-ssl-verify",
+        action="store_false",
+        default=True,
+        dest="ssl_verify",
+        help="Disable SSL verify",
+    )
+    p.add_argument(
         "--trace", action="store_true", default=False, help="Extra debugging"
     )
     p.add_argument("url")
@@ -22,7 +31,10 @@ def main():
 
     websocket.enableTrace(args.trace)
     wsapp = websocket.WebSocketApp(args.url, on_message=on_message)
-    wsapp.run_forever()
+    run_opts = {}
+    if not args.ssl_verify:
+        run_opts = {"sslopt": {"cert_reqs": ssl.CERT_NONE}}
+    wsapp.run_forever(**run_opts)
 
 
 if __name__ == "__main__":