|
|
@ -50,12 +50,12 @@ class CertClass (QtGui.QWidget):
|
|
|
|
|
|
|
|
|
|
|
|
layout_button = QtGui.QHBoxLayout()
|
|
|
|
layout_button = QtGui.QHBoxLayout()
|
|
|
|
|
|
|
|
|
|
|
|
Send_button = QtGui.QPushButton(_("Send request"), self)
|
|
|
|
Send_button = QtGui.QPushButton(_("Send a request"), self)
|
|
|
|
# Send_button.setFixedWidth(140)
|
|
|
|
# Send_button.setFixedWidth(140)
|
|
|
|
Send_button.clicked.connect(self.send)
|
|
|
|
Send_button.clicked.connect(self.send)
|
|
|
|
layout_button.addWidget(Send_button)
|
|
|
|
layout_button.addWidget(Send_button)
|
|
|
|
|
|
|
|
|
|
|
|
Get_button = QtGui.QPushButton(_("Get certificate"), self)
|
|
|
|
Get_button = QtGui.QPushButton(_("Get a certificate"), self)
|
|
|
|
# Get_button.setFixedWidth(140)
|
|
|
|
# Get_button.setFixedWidth(140)
|
|
|
|
Get_button.clicked.connect(self.get)
|
|
|
|
Get_button.clicked.connect(self.get)
|
|
|
|
layout_button.addWidget(Get_button)
|
|
|
|
layout_button.addWidget(Get_button)
|
|
|
@ -71,7 +71,7 @@ class CertClass (QtGui.QWidget):
|
|
|
|
self.sendlayout.setColumnStretch(1,1)
|
|
|
|
self.sendlayout.setColumnStretch(1,1)
|
|
|
|
self.sendlayout.setColumnStretch(2,1)
|
|
|
|
self.sendlayout.setColumnStretch(2,1)
|
|
|
|
|
|
|
|
|
|
|
|
self.GroupBoxSend = QtGui.QGroupBox(_('Certificate signing request'))
|
|
|
|
self.GroupBoxSend = QtGui.QGroupBox(_('Certificate signature request'))
|
|
|
|
# self.GroupBoxSend.setContentsMargins(10,0,0,0)
|
|
|
|
# self.GroupBoxSend.setContentsMargins(10,0,0,0)
|
|
|
|
self.GroupBoxSend.setLayout(self.sendlayout)
|
|
|
|
self.GroupBoxSend.setLayout(self.sendlayout)
|
|
|
|
|
|
|
|
|
|
|
@ -96,23 +96,23 @@ class CertClass (QtGui.QWidget):
|
|
|
|
by_host = self.send_host.text()
|
|
|
|
by_host = self.send_host.text()
|
|
|
|
|
|
|
|
|
|
|
|
if by_host == '':
|
|
|
|
if by_host == '':
|
|
|
|
show_msg (_('Enter Hostname or IP adress'), \
|
|
|
|
show_msg (_('Enter the hostname or the IP address'), \
|
|
|
|
_('Field "Host" Error!'))
|
|
|
|
_('Incorrect "Host" value!'))
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
port = self.send_port.text()
|
|
|
|
port = self.send_port.text()
|
|
|
|
|
|
|
|
|
|
|
|
if port == '' or not port.isdigit():
|
|
|
|
if port == '' or not port.isdigit():
|
|
|
|
show_msg (_('Enter Port'), _('Field "Port" Error!'))
|
|
|
|
show_msg (_('Enter the port number'), _('Incorrect "Port" value!'))
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
|
|
|
|
|
|
|
|
# send request
|
|
|
|
# send request
|
|
|
|
cert_path = self.default_cert_path
|
|
|
|
cert_path = self.default_cert_path
|
|
|
|
|
|
|
|
|
|
|
|
if os.path.exists(cert_path + 'req_id'):
|
|
|
|
if os.path.exists(cert_path + 'req_id'):
|
|
|
|
text = _("You have sent a request to sign the certificate!")
|
|
|
|
text=_("You have already sent a request to sign the certificate!")
|
|
|
|
informative_text = _("request id - %s") \
|
|
|
|
informative_text = _("request id - %s") \
|
|
|
|
%open(cert_path + 'req_id', 'r').read()+'\n' \
|
|
|
|
%open(cert_path + 'req_id', 'r').read()+'\n' \
|
|
|
|
+ _("Send new request?")
|
|
|
|
+ _("Send a new request?")
|
|
|
|
reply = show_question(self, text, informative_text,
|
|
|
|
reply = show_question(self, text, informative_text,
|
|
|
|
title = _('Calculate Console'))
|
|
|
|
title = _('Calculate Console'))
|
|
|
|
|
|
|
|
|
|
|
@ -131,13 +131,14 @@ class CertClass (QtGui.QWidget):
|
|
|
|
except (KeyboardInterrupt, urllib2.URLError), e:
|
|
|
|
except (KeyboardInterrupt, urllib2.URLError), e:
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
show_msg(e.reason.strerror.decode('utf-8') \
|
|
|
|
show_msg(e.reason.strerror.decode('utf-8') \
|
|
|
|
, _("Close. Connecting Error."), self)
|
|
|
|
, _("Closing. Connection error."), self)
|
|
|
|
except (UnicodeDecodeError, UnicodeEncodeError):
|
|
|
|
except (UnicodeDecodeError, UnicodeEncodeError):
|
|
|
|
show_msg(e.reason.strerror, \
|
|
|
|
show_msg(e.reason.strerror, \
|
|
|
|
_("Close. Connecting Error."), self)
|
|
|
|
_("Closing. Connection error."), self)
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
except (UnicodeDecodeError, UnicodeEncodeError):
|
|
|
|
except (UnicodeDecodeError, UnicodeEncodeError):
|
|
|
|
show_msg (_('Enter Hostname or IP adress'), _('Input Error'), self)
|
|
|
|
show_msg (_('Enter the hostname or the IP address'),
|
|
|
|
|
|
|
|
_('Input error'), self)
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
self.client.wsdl.services[0].setlocation(url)
|
|
|
|
self.client.wsdl.services[0].setlocation(url)
|
|
|
|
try:
|
|
|
|
try:
|
|
|
@ -152,8 +153,9 @@ class CertClass (QtGui.QWidget):
|
|
|
|
self.csr_file = cert_path + server_host_name +'.csr'
|
|
|
|
self.csr_file = cert_path + server_host_name +'.csr'
|
|
|
|
if os.path.exists(key) and os.path.exists(self.csr_file):
|
|
|
|
if os.path.exists(key) and os.path.exists(self.csr_file):
|
|
|
|
|
|
|
|
|
|
|
|
text = _('Private Key and Request exists!')
|
|
|
|
text = _('The private key and the request now exist!')
|
|
|
|
informative_text = _("Create new Private Key and Request?")
|
|
|
|
informative_text = \
|
|
|
|
|
|
|
|
_("Create a new private key and signature request?")
|
|
|
|
reply = show_question(self, text, informative_text,
|
|
|
|
reply = show_question(self, text, informative_text,
|
|
|
|
title = _('Calculate Console'))
|
|
|
|
title = _('Calculate Console'))
|
|
|
|
|
|
|
|
|
|
|
@ -183,18 +185,19 @@ class CertClass (QtGui.QWidget):
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
del (self.client)
|
|
|
|
del (self.client)
|
|
|
|
if int(res) < 0:
|
|
|
|
if int(res) < 0:
|
|
|
|
show_msg (_("This server can not sign certificate!"), parent=self)
|
|
|
|
show_msg (_("This server has not signed the certificate!"),
|
|
|
|
|
|
|
|
parent=self)
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
fc = open(self.default_cert_path + 'req_id', 'w')
|
|
|
|
fc = open(self.default_cert_path + 'req_id', 'w')
|
|
|
|
fc.write(res)
|
|
|
|
fc.write(res)
|
|
|
|
fc.close()
|
|
|
|
fc.close()
|
|
|
|
show_msg ( _("Your request id - %s") %res, parent = self)
|
|
|
|
show_msg ( _("Your request ID = %s") %res, parent = self)
|
|
|
|
return 0
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
def get(self):
|
|
|
|
cert_path = self.default_cert_path
|
|
|
|
cert_path = self.default_cert_path
|
|
|
|
if not os.path.exists(cert_path + 'req_id'):
|
|
|
|
if not os.path.exists(cert_path + 'req_id'):
|
|
|
|
show_msg (_("request was not sent or deleted file %s") \
|
|
|
|
show_msg (_("Request not sent, or file %s deleted") \
|
|
|
|
%(cert_path + 'req_id'), self)
|
|
|
|
%(cert_path + 'req_id'), self)
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
fc = open(cert_path + 'req_id', 'r')
|
|
|
|
fc = open(cert_path + 'req_id', 'r')
|
|
|
@ -203,13 +206,14 @@ class CertClass (QtGui.QWidget):
|
|
|
|
|
|
|
|
|
|
|
|
from_host = self.send_host.text()
|
|
|
|
from_host = self.send_host.text()
|
|
|
|
if from_host == '':
|
|
|
|
if from_host == '':
|
|
|
|
show_msg (_('Enter Hostname or IP adress'), \
|
|
|
|
show_msg (_('Enter the hostname or the IP address'), \
|
|
|
|
_('Field "Host" Error!'), self)
|
|
|
|
_('Incorrect "Host" value!'), self)
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
port = self.send_port.text()
|
|
|
|
port = self.send_port.text()
|
|
|
|
|
|
|
|
|
|
|
|
if port == '' or not port.isdigit():
|
|
|
|
if port == '' or not port.isdigit():
|
|
|
|
show_msg (_('Enter Port'), _('Field "Port" Error!'), self)
|
|
|
|
show_msg (_('Enter the port number'), _('Incorrect "Port" value!'),
|
|
|
|
|
|
|
|
self)
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
|
|
|
|
|
|
|
|
url = "https://%s:%s/?wsdl" %(from_host, port)
|
|
|
|
url = "https://%s:%s/?wsdl" %(from_host, port)
|
|
|
@ -219,12 +223,12 @@ class CertClass (QtGui.QWidget):
|
|
|
|
transport = HTTPSClientCertTransport(None, None, \
|
|
|
|
transport = HTTPSClientCertTransport(None, None, \
|
|
|
|
cert_path, parent = self.ClientObj))
|
|
|
|
cert_path, parent = self.ClientObj))
|
|
|
|
except (KeyboardInterrupt, urllib2.URLError), e:
|
|
|
|
except (KeyboardInterrupt, urllib2.URLError), e:
|
|
|
|
show_msg(_("Error code: %s") %e, _("Close. Connecting Error."), \
|
|
|
|
show_msg(_("Error code: %s") %e, _("Closing. Connection error."),\
|
|
|
|
self)
|
|
|
|
self)
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
except (UnicodeDecodeError, UnicodeEncodeError):
|
|
|
|
except (UnicodeDecodeError, UnicodeEncodeError):
|
|
|
|
show_msg (_('Enter Hostname or IP adress'), \
|
|
|
|
show_msg (_('Enter the hostname or the IP address'), \
|
|
|
|
_('Input Error'), self)
|
|
|
|
_('Input error'), self)
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
client.wsdl.services[0].setlocation(url)
|
|
|
|
client.wsdl.services[0].setlocation(url)
|
|
|
|
try:
|
|
|
|
try:
|
|
|
@ -235,7 +239,7 @@ class CertClass (QtGui.QWidget):
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
|
|
|
|
|
|
|
|
if not os.path.exists(cert_path + server_host_name + '.csr'):
|
|
|
|
if not os.path.exists(cert_path + server_host_name + '.csr'):
|
|
|
|
show_msg(_('Request %s not found on client side') \
|
|
|
|
show_msg(_('Request %s not found on the client’s side') \
|
|
|
|
%(cert_path + server_host_name + '.csr'))
|
|
|
|
%(cert_path + server_host_name + '.csr'))
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
|
|
|
|
|
|
|
@ -258,20 +262,21 @@ class CertClass (QtGui.QWidget):
|
|
|
|
ca_root = None
|
|
|
|
ca_root = None
|
|
|
|
# show_msg(e.message)
|
|
|
|
# show_msg(e.message)
|
|
|
|
if cert == '1':
|
|
|
|
if cert == '1':
|
|
|
|
show_msg (_('Request to sign is rejected!'))
|
|
|
|
show_msg (_('Signature request rejected!'))
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
elif cert == '2':
|
|
|
|
elif cert == '2':
|
|
|
|
show_msg (_("Request for the signing has not yet reviewed.\n") + \
|
|
|
|
show_msg (_("The request has not been reviewed yet.") + '\n' + \
|
|
|
|
_("Your request id - %s") %req_id)
|
|
|
|
_("Your request ID = %s") %req_id)
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
elif cert == '3':
|
|
|
|
elif cert == '3':
|
|
|
|
show_msg (_("Request on signature does not match sent earlier."))
|
|
|
|
show_msg (_('Either the request or the signature does not match '
|
|
|
|
|
|
|
|
'the earlier ones.'))
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
fc = open(cert_path + server_host_name + '.crt', 'w')
|
|
|
|
fc = open(cert_path + server_host_name + '.crt', 'w')
|
|
|
|
fc.write(cert)
|
|
|
|
fc.write(cert)
|
|
|
|
fc.close()
|
|
|
|
fc.close()
|
|
|
|
os.unlink(cert_path + 'req_id')
|
|
|
|
os.unlink(cert_path + 'req_id')
|
|
|
|
show_msg (_('OK. Certificate save. Your certificate id = %s') %req_id)
|
|
|
|
show_msg (_('Certificate saved. Your certificate ID = %s') %req_id)
|
|
|
|
|
|
|
|
|
|
|
|
if ca_root:
|
|
|
|
if ca_root:
|
|
|
|
system_ca_db = self.ClientObj.VarsApi.Get('cl_glob_root_cert')
|
|
|
|
system_ca_db = self.ClientObj.VarsApi.Get('cl_glob_root_cert')
|
|
|
@ -321,20 +326,22 @@ class CertClass (QtGui.QWidget):
|
|
|
|
fc.close()
|
|
|
|
fc.close()
|
|
|
|
|
|
|
|
|
|
|
|
if not filename:
|
|
|
|
if not filename:
|
|
|
|
show_msg (_('Not found field "CN" in root certificate!'))
|
|
|
|
show_msg \
|
|
|
|
|
|
|
|
(_('Field "CN" not found in the root certificate!'))
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
|
|
|
|
|
|
|
|
fd = open(cl_client_cert_dir + '/ca/' + filename, 'w')
|
|
|
|
fd = open(cl_client_cert_dir + '/ca/' + filename, 'w')
|
|
|
|
fd.write(ca_root)
|
|
|
|
fd.write(ca_root)
|
|
|
|
fd.close()
|
|
|
|
fd.close()
|
|
|
|
|
|
|
|
|
|
|
|
user_root_cert = self.ClientObj.VarsApi.Get('cl_user_root_cert')
|
|
|
|
user_root_cert = self.ClientObj.VarsApi.Get \
|
|
|
|
|
|
|
|
('cl_user_root_cert')
|
|
|
|
user_root_cert = user_root_cert.replace("~",homePath)
|
|
|
|
user_root_cert = user_root_cert.replace("~",homePath)
|
|
|
|
fa = open(user_root_cert, 'a')
|
|
|
|
fa = open(user_root_cert, 'a')
|
|
|
|
fa.write(ca_root)
|
|
|
|
fa.write(ca_root)
|
|
|
|
fa.close()
|
|
|
|
fa.close()
|
|
|
|
_print (_("filename = "), filename)
|
|
|
|
_print (_("Filename = "), filename)
|
|
|
|
show_msg (_("Root Certificate Add") + '\n' + filename)
|
|
|
|
show_msg (_("Root certificate added") + '\n' + filename)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
_print (_("file with ca certificates exists"))
|
|
|
|
_print (_("File with CA certificates now exists"))
|
|
|
|
return 0
|
|
|
|
return 0
|
|
|
|