From 3a8320a1d73444b3bb823300e94c3e2ee85fd6ef Mon Sep 17 00:00:00 2001 From: Cedric Brandily Date: Fri, 1 Apr 2016 23:42:27 +0200 Subject: Support client certificate/key This change enables to specify a client certificate/key with: * usual CLI options (--os-cert/--os-key) * usual environment variables ($OS_CERT/$OS_KEY) * os-client-config Change-Id: Ibeaaa5897ae37b37c1e91f3e47076e4e8e4a8ded Closes-Bug: #1565112 --- openstackclient/common/clientmanager.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'openstackclient/common/clientmanager.py') diff --git a/openstackclient/common/clientmanager.py b/openstackclient/common/clientmanager.py index 56ddcbad..6d23b55e 100644 --- a/openstackclient/common/clientmanager.py +++ b/openstackclient/common/clientmanager.py @@ -110,6 +110,15 @@ class ClientManager(object): self._cacert = verify self._insecure = False + # Set up client certificate and key + # NOTE(cbrandily): This converts client certificate/key to requests + # cert argument: None (no client certificate), a path + # to client certificate or a tuple with client + # certificate/key paths. + self._cert = self._cli_options.cert + if self._cert and self._cli_options.key: + self._cert = self._cert, self._cli_options.key + # Get logging from root logger root_logger = logging.getLogger('') LOG.setLevel(root_logger.getEffectiveLevel()) @@ -194,6 +203,7 @@ class ClientManager(object): auth=self.auth, session=request_session, verify=self._verify, + cert=self._cert, user_agent=USER_AGENT, ) -- cgit v1.2.1