def test_dump_certs(self): # Dump Cert Cache and returning a cert cache text table as a list certs_list = Nm.nm_dump_cert_cache(sendMode, CPD_IPV6_AP) # print "certs output: ", certs_list # print '{:s}'.format(certs_list) # Load output Cert Cache table into a list certs_array = [] lines = certs_list.split('\n') # split by rows for rows in lines: elements = rows.split('\t') print elements certs_array.append(elements) for e in certs_array: print e
def test_removing_OP_chained_path_certs(self): # Establihsing ALS connection and sendig first command via secured ALS reqId = Nm.random_with_N_digits(5) blobFileIn = CERTS_PATH + BLOB_FILE privkeyFileIn = CERTS_PATH + PRIVKEY_FILE timeOut = 30 replyType = 7 # BC=0x1 + Blob=0x4 for nm.nm_sec_assoc assoc replyType2 = '03' # HMAC, ShA256 for secured send comands IPV6 = 'fe80::213:50ff:fe30:5b5e' #'fe80::213:5005:008f:deb2' #'fe80::213:50ff:fe30:5b5e' print "Trying to establish ALS Connection...\n" (seqNum, assocId, ss) = Nm.nm_establish_ALS_connection( sendMode, IPV6, timeOut=60, reqId=12345, replyType=5, replyType2='03', blobFileIn=CERTS_PATH + BLOB_FILE, privkeyFileIn=CERTS_PATH + PRIVKEY_FILE) # seqNum = seqNum + 15 # Making a second secured command request via ALS cmdString = " certs esdump 4 " print "Trying to send command via secured ALSConnection...\n" (seqNum, assocId, ss) = Nm.nm_als_secured_commands_send(sendMode, cmdString, seqNum, assocId, ss, IPV6, timeOut, replyType2) print "Return for next command request for: seqNum;\'%d\', assocId:\'%s\', and sharedsecret:\'%s\' \n" % ( seqNum, assocId, ss) # Removing DL cert:#1281, #1282 print "Removing DL cert 1280....\n" #Nm.nm_remove_cert(sendMode, IPV6, '1280') seqNum = seqNum + 15 privateID = 1283 cmdString = " certs erase " + str(privateID) (seqNum, assocId, ss) = Nm.nm_als_secured_commands_send(sendMode, cmdString, seqNum, assocId, ss, IPV6, timeOut, replyType2) print "Return for next command request for: seqNum;\'%d\', assocId:\'%s\', and sharedsecret:\'%s\' \n" % ( seqNum, assocId, ss) print "Removing DL cert 1283....\n" #Nm.nm_remove_cert(sendMode, IPV6, '1283') seqNum = seqNum + 15 privateID = 1281 cmdString = " certs erase " + str(privateID) (seqNum, assocId, ss) = Nm.nm_als_secured_commands_send(sendMode, cmdString, seqNum, assocId, ss, IPV6, timeOut, replyType2) print "Return for next command request for: seqNum;\'%d\', assocId:\'%s\', and sharedsecret:\'%s\' \n" % ( seqNum, assocId, ss) # Removing DLCA cert: #1283 print "Removing DLCA cert....\n" # Nm.nm_remove_cert(sendMode, IPV6, '1025') seqNum = seqNum + 15 privateID = 1283 cmdString = " certs erase " + str(privateID) (seqNum, assocId, ss) = Nm.nm_als_secured_commands_send(sendMode, cmdString, seqNum, assocId, ss, IPV6, timeOut, replyType2) print "Return for next command request for: seqNum;\'%d\', assocId:\'%s\', and sharedsecret:\'%s\' \n" % ( seqNum, assocId, ss) # Removing OP cert: #1027 print "Deleting Op cert and subordinates...\n" # Nm.nm_certs_delete_op(sendMode, IPV6) seqNum = seqNum + 15 cmdString = " certs delete_op" (seqNum, assocId, ss) = Nm.nm_als_secured_commands_send(sendMode, cmdString, seqNum, assocId, ss, IPV6, timeOut, replyType2) print "Return for next command request for: seqNum;\'%d\', assocId:\'%s\', and sharedsecret:\'%s\' \n" % ( seqNum, assocId, ss) """ seqNum = seqNum + 15 print "Deleting NMENITY Cert...\n" #Nm.nm_certs_delete_op(sendMode, IPV6) seqNum = seqNum + 15 privateID = "0x200010" cmdString = " certs erase " + str(privateID) (seqNum, assocId, ss) = Nm.nm_als_secured_commands_send(sendMode, cmdString, seqNum, assocId, ss, IPV6, timeOut, replyType2) print "Return for next command request for: seqNum;\'%d\', assocId:\'%s\', and sharedsecret:\'%s\' \n" % ( seqNum, assocId, ss) seqNum = seqNum + 15 print "Deleting EBOCA CERT...\n" #Nm.nm_certs_delete_op(sendMode, IPV6) seqNum = seqNum + 15 privateID = "0x20000f" cmdString = " certs erase " + str(privateID) (seqNum, assocId, ss) = Nm.nm_als_secured_commands_send(sendMode, cmdString, seqNum, assocId, ss, IPV6, timeOut, replyType2) print "Return for next command request for: seqNum;\'%d\', assocId:\'%s\', and sharedsecret:\'%s\' \n" % ( seqNum, assocId, ss) """ #NOTE: if all failed, try app_sysvar delete:360 (the certs cache) # Removing APP_SYSVAR 360 cert: print "Deleting app_sysvar:360...\n" seqNum = seqNum + 15 cmdString = " app_sysvar delete:360" (seqNum, assocId, ss) = Nm.nm_als_secured_commands_send(sendMode, cmdString, seqNum, assocId, ss, IPV6, timeOut, replyType2) print "Return for next command request for: seqNum;\'%d\', assocId:\'%s\', and sharedsecret:\'%s\' \n" % ( seqNum, assocId, ss) #print "Deleting out app_sysvar:360 for certs cache...\n" #ID = 360 #Nm.nm_delete_sysvar(sendMode, IPV6, ID) Nm.nm_dump_cert_cache(sendMode, IPV6) seqNum = seqNum + 15 ret = Nm.nm_teardown_ALS_connection(sendMode, seqNum, assocId, ss, IPV6) print "Please restart your NIC before checking: certs esdump 4 again!\n"