add support for client SSL certificate and key

This commit is contained in:
Matthias Lehmann 2014-01-28 16:16:48 +01:00
parent 43cc3e7ddb
commit 14583a2efa
2 changed files with 28 additions and 0 deletions

View File

@ -465,6 +465,27 @@ network.add_argument(
"""
)
network.add_argument(
'--ssl-cert',
default=None,
help="""
You can specify a local cert to use as client side SSL certificate.
This file may either contain both private key and certificate or you may
specify --ssl-key separately.
"""
)
network.add_argument(
'--ssl-key',
default=None,
help="""
The private key to use with SSL. Only needed if --ssl-cert is given and the
certificate file does not contain the private key.
"""
)
network.add_argument(
'--timeout',
type=float,

View File

@ -73,6 +73,12 @@ def get_requests_kwargs(args):
auth_plugin = plugin_manager.get_auth_plugin(args.auth_type)()
credentials = auth_plugin.get_auth(args.auth.key, args.auth.value)
cert = None
if args.ssl_cert:
cert = args.ssl_cert
if args.ssl_key:
cert = (cert, args.ssl_key)
kwargs = {
'stream': True,
'method': args.method.lower(),
@ -83,6 +89,7 @@ def get_requests_kwargs(args):
'yes': True,
'no': False
}.get(args.verify, args.verify),
'cert': cert,
'timeout': args.timeout,
'auth': credentials,
'proxies': dict((p.key, p.value) for p in args.proxy),