def CACertDeleted(self, s): l = [s] test_util.BindUnbindCACert(self.GetCurDUT().sess, self.lineEdit_name.text(), l, isunbind=True) return
def FromFileStr(cls, jstring, sess=None): d = json.loads(jstring) d = json.loads(d['val']) try: svc = SERVICE.service.get(sess, d['name']) if (svc): print 'deleting existing service {}'.format(d['name']) SERVICE.service.delete(sess, svc) except NITROEXCEPTION as e: print 'FromFileStr: nitro exception: {}'.format(e.message) except Exception as e: print 'FromFileStr: exception: {}'.format(e.message) obj = SSLServiceEntity(d['name'], d['ip'], d['port'], d['type'], sess, d['nsip']) obj.fromfiledict = d obj.sess = sess if not obj.Create(): print 'obj.Create() failed' return None l = d['calist'] if len(l) > 0: print 'binding ca cert {}'.format(l) test_util.BindUnbindCACert(sess, d['name'], l, isunbind=False, isservice=True) l = d['clientcert'] if l: print 'binding client cert {}'.format(l) test_util.BindUnbindServerCert(sess, d['name'], l, isunbind=False, isservice=True) obj.sslsvc.sessreuse = d['sessreuse'] obj.sslsvc.sesstimeout = d['sesstimeout'] obj.sslsvc.ssl3 = d['ssl3'] obj.sslsvc.tls1 = d['tls1'] obj.sslsvc.tls11 = d['tls11'] obj.sslsvc.tls12 = d['tls12'] obj.sslsvc.sendclosenotify = d['sendclosenotify'] obj.sslsvc.clientcert = d['clientcert'] obj.sslsvc.pushenctrigger = d['pushenctrigger'] obj.sslsvc.serverauth = d['serverauth'] obj.sslsvc.commonname = d['commonname'] obj.boundciphers = d['boundciphers'] obj.ApplySavedCiphers(sess) return obj
def CACertDeleted(self, s): print 'CACertDeleted {}'.format(s) l = [s] #test_util.BindUnbindCACert(self.GetCurDUT().sess,self.lineEdit_name.text(),l,isunbind=True,isservice=True) obj = self.container.GetBackendObj() if obj: obj.calist.remove(s) sess = obj.sess test_util.BindUnbindCACert(sess, self.lineEdit_name.text(), l, isunbind=True, isservice=True) return
def CACertAdded(self, s): print 'CACertAdded {}'.format(s) obj = self.container.GetBackendObj() if not obj: self.pending_calist.append(s) return sess = obj.sess l = [s] #test_util.BindUnbindCACert(self.GetCurDUT().sess,self.lineEdit_name.text(),l,isunbind=False,isservice=True) test_util.BindUnbindCACert(sess, self.lineEdit_name.text(), l, isunbind=False, isservice=True) obj.calist.append(s) print 'added cacert {} to calist'.format(s) return
def FromFileStr(cls, jstring, sess=None): d = json.loads(jstring) d = json.loads(d['val']) nsip = d['nsip'] try: lb = LBVSERVER.lbvserver.get(sess, d['name']) if (lb): LBVSERVER.lbvserver.delete(sess, lb) except NITROEXCEPTION as e: pass except Exception as e: pass obj = SSLVServerEntity(d['name'], d['ip'], d['port'], d['type'], sess, nsip) obj.fromfiledict = d if not obj.Create(): print 'obj.Create() failed' return None l = d['calist'] if len(l) > 0: test_util.BindUnbindCACert(sess, d['name'], l, isunbind=False) obj.calist = l l = d['snilist'] if len(l) > 0: test_util.BindUnbindSniCert(sess, d['name'], l, isunbind=False) obj.snilist = l l = d['servercert'] if l: test_util.BindUnbindServerCert(sess, d['name'], l, isunbind=False) obj.servercert = l[0] obj.ssl.sessreuse = d['sessreuse'] obj.ssl.sesstimeout = d['sesstimeout'] obj.ssl.ssl3 = d['ssl3'] obj.ssl.tls1 = d['tls1'] obj.ssl.tls11 = d['tls11'] obj.ssl.tls12 = d['tls12'] obj.ssl.sendclosenotify = d['sendclosenotify'] obj.ssl.clientauth = d['clientauth'] obj.ssl.clientcert = d['clientcert'] obj.ssl.pushenctrigger = d['pushenctrigger'] obj.ssl.dh = d['dh'] obj.ssl.dhfile = d['dhfile'] obj.ssl.dhcount = d['dhcount'] obj.ssl.ersa = d['ersa'] obj.ssl.ersacount = d['ersacount'] obj.ssl.snienable = d['snienable'] obj.boundciphers = d['boundciphers'] obj.ssl.cipherurl = None obj.ssl.sslv2url = None obj.ssl.dtlsprofilename = None obj.ssl.sslprofile = None obj.ApplySavedCiphers(sess) try: SSLVSERVER.sslvserver.update(sess, obj.ssl) except NITROEXCEPTION as e: print 'Update Vserver failed : {}'.format(e.message) ret = False except Exception as e: print 'Update Vserver failed : {}'.format(e.message) ret = False return obj
def UpdateEntity(self, obj): ret = True clientcertlist = [] cacertlist = [] dut = self.GetCurDUT() svcname = self.lineEdit_name.text() cslist = [] if self.pendingcipherlist: print 'UpdateEntity: svcname {}'.format(svcname) test_util.BindUnbindCipher(dut.sess, svcname, self.pendingcipherlist, cslist, isunbind=False, isservice=True) obj.boundciphers = self.pendingcipherlist self.pendingcipherlist = None if self.pending_calist: test_util.BindUnbindCACert(dut.sess, svcname, self.pending_calist, isunbind=False, isservice=True) obj.calist = self.pending_calist self.pending_calist = None if self.pending_clientcert: test_util.BindUnbindServerCert(dut.sess, svcname, self.pending_clientcert, isunbind=False, isservice=True) obj.clientcert = self.pending_clientcert self.pending_clientcert = None if self.radioButton_reuse.isChecked(): obj.sslsvc.sessreuse = 'ENABLED' try: obj.sslsvc.sesstimeout = int(self.lineEdit_idletimeout.text()) except ValueError as e: obj.sslsvc.sesstimeout = 120 self.lineEdit_idletimeout.setText('120') else: obj.sslsvc.sessreuse = 'DISABLED' obj.sslsvc.sesstimeout = None self.lineEdit_idletimeout.setText('') if self.radioButton_ssl3.isChecked(): obj.sslsvc.ssl3 = 'ENABLED' else: obj.sslsvc.ssl3 = 'DISABLED' if self.radioButton_tls1.isChecked(): obj.sslsvc.tls1 = 'ENABLED' else: obj.sslsvc.tls1 = 'DISABLED' if self.radioButton_tls11.isChecked(): obj.sslsvc.tls11 = 'ENABLED' else: obj.sslsvc.tls11 = 'DISABLED' if self.radioButton_tls12.isChecked(): obj.sslsvc.tls12 = 'ENABLED' else: obj.sslsvc.tls12 = 'DISABLED' if self.radioButton_sendcn.isChecked(): obj.sslsvc.sendclosenotify = 'YES' else: obj.sslsvc.sendclosenotify = 'NO' if self.radioButton_sighash.isChecked(): obj.sslsvc.strictsigdigestcheck = 'ENABLED' else: obj.sslsvc.strictsigdigestcheck = 'DISABLED' if self.radioButton_ersa.isChecked(): obj.sslsvc.ersa = 'ENABLED' try: ersacount = int(self.lineEdit_ersacount.text()) except ValueError as e: obj.sslsvc.ersa = 'DISABLED' ersacount = None obj.sslsvc.ersacount = ersacount self.lineEdit_ersacount.setText(str(ersacount)) else: obj.sslsvc.ersa = 'DISABLED' obj.sslsvc.ersacount = None if self.radioButton_serverauth.isChecked(): obj.sslsvc.serverauth = 'ENABLED' obj.sslsvc.commonname = self.lineEdit_commonname.text() else: obj.sslsvc.serverauth = 'DISABLED' obj.sslsvc.commonname = None obj.sslsvc.dhfile = None obj.sslsvc.cipherurl = None obj.sslsvc.sslv2url = None obj.sslsvc.dtlsprofilename = None obj.sslsvc.sslprofile = None obj.sslsvc.pushenctrigger = None t = self.lineEdit_maxreq.text() if t and len(t) > 0: obj.svc.maxreq = int(t) obj.svc.cipheader = None obj.svc.sc = None obj.svc.serverid = None obj.svc.weight = None obj.svc.monitor_name_svc = None obj.svc.tcpprofilename = None obj.svc.httpprofilename = None obj.svc.netprofile = None obj.svc.dnsprofilename = None obj.svc.hashid = None obj.svc.comment = None obj.sslsvc.clientcert = None sess = self.curDUT.sess try: SERVICE.service.update(sess, obj.svc) SSLSERVICE.sslservice.update(sess, obj.sslsvc) except NITROEXCEPTION as e: print 'UpdateEntity Nitro service failed : {}'.format(e.message) ret = False raise e except Exception as e: print 'UpdateEntity service failed : {}'.format(e.message) ret = False raise e return ret
def FillFromDict(self, d, nsip): #dut = self.GetCurDUT() #dut = d['dut'] dut = self.GetDUTByIP(nsip) self.lineEdit_name.setText(d['name']) self.lineEdit_ip.setText(d['ip']) self.lineEdit_port.setText(str(d['port'])) if d['sessreuse'] == 'ENABLED': self.radioButton_reuse.setChecked(True) self.lineEdit_idletimeout.setText(d['sesstimeout']) else: self.radioButton_reuse.setChecked(False) self.lineEdit_idletimeout.setText('') if d['ssl3'] == 'ENABLED': self.radioButton_ssl3.setChecked(True) else: self.radioButton_ssl3.setChecked(False) if d['tls1'] == 'ENABLED': self.radioButton_tls1.setChecked(True) else: self.radioButton_tls1.setChecked(False) if d['tls11'] == 'ENABLED': self.radioButton_tls11.setChecked(True) else: self.radioButton_tls11.setChecked(False) if d['tls12'] == 'ENABLED': self.radioButton_tls12.setChecked(True) else: self.radioButton_tls12.setChecked(False) if d['sendclosenotify'] == 'YES': self.radioButton_sendcn.setChecked(True) else: self.radioButton_sendcn.setChecked(False) if d['serverauth'] == 'ENABLED': self.radioButton_serverauth.setChecked(True) self.lineEdit_commonname.setText(str(d['commonname'])) else: self.radioButton_serverauth.setChecked(False) self.lineEdit_commonname.setText('') v = d['pushenctrigger'] if v == 'Always': self.comboBox_push.setCurrentIndex(0) elif v == 'Ignore': self.comboBox_push.setCurrentIndex(1) elif v == 'Merge': self.comboBox_push.setCurrentIndex(2) elif v == 'Timer': self.comboBox_push.setCurrentIndex(3) self.FillCerts() clist = d['calist'] if len(clist) > 0: test_util.BindUnbindCACert(dut.sess, d['name'], clist, isunbind=False, isservice=True) for c in clist: self.listWidget_ca_cert.AddToList(c) clist = d['clientcert'] if clist: test_util.BindUnbindServerCert(dut.sess, d['name'], clist, isunbind=False, isservice=True) self.listWidget_server_cert.AddToList(clist)