Repository :
http://git.fedorahosted.org/cgit/cura-tools.git
On branch : master
---------------------------------------------------------------
commit 97fdb3b34f067591a81f477c2e802c5f65fea185
Author: Peter Hatina <phatina(a)redhat.com>
Date: Fri Dec 13 10:56:52 2013 +0100
fix certificate's subject validation
---------------------------------------------------------------
cli/lmi/shell/LMIBaseClient.py | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/cli/lmi/shell/LMIBaseClient.py b/cli/lmi/shell/LMIBaseClient.py
index 2618997..c2d78e9 100644
--- a/cli/lmi/shell/LMIBaseClient.py
+++ b/cli/lmi/shell/LMIBaseClient.py
@@ -15,6 +15,7 @@
import sys
import pywbem
+import urlparse
from LMIObjectFactory import LMIObjectFactory
from LMIReturnValue import LMIReturnValue
@@ -63,7 +64,7 @@ class LMIBaseClient(object):
**NOTE:** see :py:class:`pywbem.cim_operations.WBEMConnection`
"""
- return bool(rcode)
+ return bool(rcode) and cert.get_subject().commonName == hostname
# Set remaining arguments
conn_type = kwargs.pop("conn_type", LMIBaseClient.CONN_TYPE_WBEM)
@@ -80,6 +81,9 @@ class LMIBaseClient(object):
if conn_type == LMIBaseClient.CONN_TYPE_PEGASUS_UDS:
self._cliconn = pywbem.PegasusUDSConnection()
else:
+ # Get hostname from URI. It is necessary to split the netloc
+ # member, because it contains also port number.
+ hostname = urlparse.urlparse(self._uri).netloc.split(":")[0]
self._cliconn = pywbem.WBEMConnection(self._uri,
(self._username, password),
x509={"key_file" : key_file, "cert_file" :
cert_file},