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},