Add argparse to set host, port
authorRalf Jung <post@ralfj.de>
Mon, 21 Jul 2014 09:03:20 +0000 (11:03 +0200)
committerRalf Jung <post@ralfj.de>
Mon, 21 Jul 2014 09:03:20 +0000 (11:03 +0200)
ssl-check

index ae3d26fb934e88245c182473592e6e7bbba233b4..3b8a4d060084cc584871c92fc8b28b40bb3e836b 100755 (executable)
--- a/ssl-check
+++ b/ssl-check
@@ -1,5 +1,5 @@
 #!/usr/bin/python3
 #!/usr/bin/python3
-import subprocess, sys
+import subprocess, sys, argparse
 from collections import OrderedDict
 from enum import Enum
 
 from collections import OrderedDict
 from enum import Enum
 
@@ -76,4 +76,27 @@ def test_host(host, port, options=[]):
     finish_progress()
     return results
 
     finish_progress()
     return results
 
-print(test_host('ralfj.de', 443))
+if __name__ == "__main__":
+    parser = argparse.ArgumentParser(description='Check SSL ciphers supported by a host')
+    parser.add_argument("host", metavar='HOST[:PORT]',
+                        help="The host to check")
+    args = parser.parse_args()
+    
+    # get host, port
+    if ':' in args.host:
+        host, port = args.host.split(':')
+    else:
+        host = args.host
+        port = 443
+    
+    # run the test
+    results = test_host(host, port)
+    for protocol, ciphers in results.items():
+        print(protocol+":")
+        if ciphers is None:
+            print("    Is not supported by client or server")
+        else:
+            for cipher, supported in ciphers.items():
+                if supported:
+                    print("    "+cipher)
+        print()