From 9bd269c26a02d94f16d7c39f3cb0a4cd46bb40b1 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Sun, 20 Jan 2013 22:37:43 +1300 Subject: Add support for client certificates - pathod request logs now include a clientcert member with details on the client cert, or None if there wasn't one. - pathoc has a -C option to specify a client certificate --- pathoc | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to 'pathoc') diff --git a/pathoc b/pathoc index 527b9a22..aa3d5bed 100755 --- a/pathoc +++ b/pathoc @@ -22,10 +22,6 @@ if __name__ == "__main__": metavar = "HOST:PORT", help="Issue an HTTP CONNECT to connect to the specified host." ) - parser.add_argument( - "-i", dest="sni", type=str, default=False, - help="SSL Server Name Indication" - ) parser.add_argument( "-n", dest='repeat', default=1, type=int, metavar="N", help='Repeat requests N times' @@ -34,10 +30,6 @@ if __name__ == "__main__": "-p", dest="port", type=int, default=None, help="Port. Defaults to 80, or 443 if SSL is active" ) - parser.add_argument( - "-s", dest="ssl", action="store_true", default=False, - help="Connect with SSL" - ) parser.add_argument( "-t", dest="timeout", type=int, default=None, help="Connection timeout" @@ -51,6 +43,24 @@ if __name__ == "__main__": help='Request specification' ) + + group = parser.add_argument_group( + 'SSL', + ) + group.add_argument( + "-s", dest="ssl", action="store_true", default=False, + help="Connect with SSL" + ) + group.add_argument( + "-C", dest="clientcert", type=str, default=False, + help="Path to a file containing client certificate and private key" + ) + group.add_argument( + "-i", dest="sni", type=str, default=False, + help="SSL Server Name Indication" + ) + + group = parser.add_argument_group( 'Controlling Output', """ @@ -59,7 +69,7 @@ if __name__ == "__main__": """ ) group.add_argument( - "-C", dest="ignorecodes", type=str, default="", + "-I", dest="ignorecodes", type=str, default="", help="Comma-separated list of response codes to ignore" ) group.add_argument( @@ -113,10 +123,10 @@ if __name__ == "__main__": try: for i in range(args.repeat): - p = pathoc.Pathoc(args.host, port, args.ssl, args.sni) + p = pathoc.Pathoc(args.host, port, ssl=args.ssl, sni=args.sni, clientcert=args.clientcert) try: p.connect(connect_to) - except tcp.NetLibError, v: + except (tcp.NetLibError, pathoc.PathocError), v: print >> sys.stderr, str(v) sys.exit(1) if args.timeout: -- cgit v1.2.3