diff --git a/console/application/cl_client.py b/console/application/cl_client.py index dddf252..f55bdd0 100644 --- a/console/application/cl_client.py +++ b/console/application/cl_client.py @@ -92,6 +92,9 @@ def connect_with_cert(cert, path_to_cert, url, args, wait_thread, clVarsCore, cert_name = cert CERT_FILE = os.path.join(path_to_cert, cert_name + '.crt') CERT_KEY = os.path.join(path_to_cert, cert_name + '.key') + if not os.path.isfile(CERT_FILE) or not os.path.isfile(CERT_KEY): + Connect_Error = 1 + return (None, 1, crypto_Error, False, None) client = None bio = M2Crypto.BIO.openfile(CERT_KEY) @@ -104,9 +107,10 @@ def connect_with_cert(cert, path_to_cert, url, args, wait_thread, clVarsCore, else: key_passwd = None try: + ca_certs = os.path.join(path_to_cert, 'ca/ca_root.crt') client = Client_suds(url, transport=HTTPSClientCertTransport \ (CERT_KEY, CERT_FILE, path_to_cert, password=key_passwd, - wait_thread = wait_thread)) + ca_certs = ca_certs, wait_thread = wait_thread)) if not wait_thread.isAlive(): wait_thread = StoppableThread() flag_thread_start = True @@ -154,7 +158,7 @@ def add_server_hostname(host, path_to_cert, server_hostname): temp_file = '' find_flag = False for line in readLinesFile(compliance_file): - adress, server_hostname = line.split(' ',1) + adress, temp_server_hostname = line.split(' ',1) if adress == host: temp_file += "%s %s\n" %(adress, server_hostname) find_flag = True @@ -371,11 +375,11 @@ def main(wait_thread): print _('Password is invalid') # delete password from daemon list clear_password(host, port) - get_name_flag = False if e: wait_thread.stop() - print _('Error: '), e - get_name_flag = False + if type(e.message) != int: + print _('Error: '), e + get_name_flag = False if get_name_flag: try: @@ -432,6 +436,7 @@ def main(wait_thread): Connect_Error = 1 crypto_Error = 0 e = None + for i in range (0, len(fit_cert_list)): cert_name = fit_cert_list.pop() client, Connect_Error, crypto_Error, passwd_flag, e = \ @@ -454,7 +459,8 @@ def main(wait_thread): return 1 if e: wait_thread.stop() - print _('Error: '), e + if type(e.message) != int: + print _('Error: '), e return 1 CERT_FILE = None diff --git a/console/application/client_class.py b/console/application/client_class.py index ce89ca4..c4c1ab0 100644 --- a/console/application/client_class.py +++ b/console/application/client_class.py @@ -64,6 +64,7 @@ class CheckingClientHTTPSConnection(CheckingHTTPSConnection): keyobj, certobj, **kw) # self.ClientObj = ClientObj self.cert_path = cert_path + self.ca_certs = ca_certs self.CRL_PATH = os.path.join(cert_path, 'ca/crl/') self.wait_thread = wait_thread @@ -359,11 +360,11 @@ class CheckingClientHTTPSConnection(CheckingHTTPSConnection): add['certfile'] = self.cert_file else: wrap_class = ssl.SSLSocket - self.sock = wrap_class(sock, ca_certs=self.ca_certs, **add) + self.sock = wrap_class(sock, ca_certs=None, **add) return 0 - except Exception, e: - print (e) + except Exception: +# print (e) HTTPSClientCertTransport.filename = None return 1 else: @@ -476,7 +477,6 @@ class HTTPSClientCertTransport(HttpTransport): raise OpenSSL.crypto.Error client_keyobj = OpenSSL.crypto.load_privatekey \ (OpenSSL.SSL.FILETYPE_PEM, file(key).read()) - Unskin(self.options).update(kwargs) self.cookiejar = CookieJar(DefaultCookiePolicy()) self.cookie_callback = cookie_callback @@ -503,4 +503,4 @@ class HTTPSClientCertTransport(HttpTransport): self.urlopener.add_handler(proxy_handler) if proxy_auth_handler: self.urlopener.add_handler(proxy_auth_handler) - self.urlopener.addheaders = [('User-agent', self.user_agent_string)] + self.urlopener.addheaders = [('User-agent', self.user_agent_string)] \ No newline at end of file diff --git a/console/application/create_cert.py b/console/application/create_cert.py index 3b5a328..276f1c3 100644 --- a/console/application/create_cert.py +++ b/console/application/create_cert.py @@ -18,7 +18,6 @@ import sys import socket from M2Crypto import RSA, X509, EVP, m2 from calculate.lib.datavars import DataVars -import gettext from calculate.lib.cl_lang import setLocalTranslate setLocalTranslate('calculate_console',sys.modules[__name__]) diff --git a/console/application/sid_func.py b/console/application/sid_func.py index 9b17cb2..887e50e 100644 --- a/console/application/sid_func.py +++ b/console/application/sid_func.py @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import sys, os +import sys from function import get_sid from calculate.lib.cl_lang import setLocalTranslate setLocalTranslate('calculate_console',sys.modules[__name__])