|
|
|
@ -128,12 +128,25 @@ def connect_with_cert(cert, path_to_cert, url, args, wait_thread, clVarsCore,
|
|
|
|
|
return None, 1, crypto_Error, False, None
|
|
|
|
|
client = None
|
|
|
|
|
|
|
|
|
|
bio = M2Crypto.BIO.openfile(CERT_KEY)
|
|
|
|
|
rsa = M2Crypto.m2.rsa_read_key(bio._ptr(), lambda *unused: "")
|
|
|
|
|
rsa_password = args.cert_passwd or ""
|
|
|
|
|
with open(CERT_KEY) as inf:
|
|
|
|
|
if 'ENCRYPTED' in inf.readline():
|
|
|
|
|
if not args.cert_passwd:
|
|
|
|
|
Connect_Error = 1
|
|
|
|
|
return None, 1, crypto_Error, False, _("RSA key contain ENCRYPTED. Use '--cert-passwd' to provide password")
|
|
|
|
|
try:
|
|
|
|
|
bio = M2Crypto.BIO.openfile(CERT_KEY)
|
|
|
|
|
rsa = M2Crypto.m2.rsa_read_key(bio._ptr(), lambda *unused: bytes(rsa_password, 'utf-8'))
|
|
|
|
|
except SystemError as e:
|
|
|
|
|
Connect_Error = 1
|
|
|
|
|
return None, 1, crypto_Error, False, _("Failed to read rsa key")
|
|
|
|
|
store_passwd = None
|
|
|
|
|
if not rsa:
|
|
|
|
|
port = args.port or clVarsCore.Get('core.cl_core_port')
|
|
|
|
|
store_passwd = get_password_from_daemon(args.host, port, wait_thread)
|
|
|
|
|
try:
|
|
|
|
|
port = args.port or clVarsCore.Get('core.cl_core_port')
|
|
|
|
|
store_passwd = get_password_from_daemon(args.host, port, wait_thread)
|
|
|
|
|
except TypeError:
|
|
|
|
|
return None, 1, crypto_Error, False, _("Failed to get password from daemon or provided password is incorrect")
|
|
|
|
|
key_passwd = store_passwd
|
|
|
|
|
er = None
|
|
|
|
|
try:
|
|
|
|
@ -141,7 +154,7 @@ def connect_with_cert(cert, path_to_cert, url, args, wait_thread, clVarsCore,
|
|
|
|
|
client = Client_suds(
|
|
|
|
|
url, transport=HTTPSClientCertTransport(
|
|
|
|
|
CERT_KEY, CERT_FILE, path_to_cert, password=key_passwd,
|
|
|
|
|
ca_certs=ca_certs, wait_thread=wait_thread))
|
|
|
|
|
ca_certs=ca_certs, wait_thread=wait_thread, rsa_password=bytes(rsa_password, 'utf-8')))
|
|
|
|
|
if not wait_thread.is_alive():
|
|
|
|
|
wait_thread = StoppableThread()
|
|
|
|
|
flag_thread_start = True
|
|
|
|
|