snmpv3 getone fails while trying via pysnmp (WrongValueError)

一世执手 提交于 2019-12-13 03:45:17

问题


while trying to run get one with pysnmp for snmpv3, getting below error

pysnmp.smi.error.WrongValueError: WrongValueError({'msg': WrongValueError(), 'name': (1, 3, 6, 1, 6, 3, 15, 1, 2, 2, 1, 5, 24, 48, 48, 48, 48, 49, 100, 51, 98, 48, 48, 48, 48, 55, 53, 100, 49, 97, 99, 49, 48, 48, 49, 48, 49, 5, 107, 107, 48, 51, 48), 'idx': 3})

from pysnmp.hlapi import *

errorIndication, errorStatus, errorIndex, varBinds = next(
getCmd(SnmpEngine(),
       UsmUserData('USERNAME',authKey='AUTHKEY', privKey='PRIVKEY', authProtocol='usmHMACSHAAuthProtocol', privProtocol='usmAESCfb256Protocol',
                           securityEngineId=OctetString(hexValue='0000303010')),
       UdpTransportTarget(('<IP-ADDR>', <PORT>)),
       ContextData(),
       ObjectType(ObjectIdentity('<MIB-FILE-NAME>','<MIB-NAME>',<INDEX>)))

The same code works for SNMP-V2 with community string instead of UsmUserData. However, not working for SNMP-V3.

The traceback is too long and no clue

File "supy.py", line 15, in <module>
ObjectType(ObjectIdentity('<MIB-FILE-NAME>','<MIB-NAME>',<INDEX>)))
 File "/usr/lib/python2.7/site-packages/pysnmp/hlapi/asyncore/sync/cmdgen.py", line 111, in getCmd
lookupMib=options.get('lookupMib', True)))
File "/usr/lib/python2.7/site-packages/pysnmp/hlapi/asyncore/cmdgen.py", line 124, in getCmd
addrName, paramsName = lcd.configure(snmpEngine, authData, transportTarget)
File "/usr/lib/python2.7/site-packages/pysnmp/hlapi/lcd.py", line 60, in configure
securityName=authData.securityName
File "/usr/lib/python2.7/site-packages/pysnmp/entity/config.py", line 159, in addV3User
(usmUserEntry.name + (13,) + tblIdx1, 'createAndGo'))
File "/usr/lib/python2.7/site-packages/pysnmp/smi/instrum.py", line 256, in writeVars
return self.flipFlopFsm(self.fsmWriteVar, varBinds, acInfo)
File "/usr/lib/python2.7/site-packages/pysnmp/smi/instrum.py", line 239, in flipFlopFsm
raise origExc
pysnmp.smi.error.WrongValueError: WrongValueError({'msg': WrongValueError(), 'name': (1, 3, 6, 1, 6, 3, 15, 1, 2, 2, 1, 5, 24, 48, 48, 48, 48, 49, 100, 51, 98, 48, 48, 48, 48, 55, 53, 100, 49, 97, 99, 49, 48, 48, 49, 48, 49, 5, 107, 107, 48, 51, 48), 'idx': 3})

Please help us with some clue here.


回答1:


Make sure your authentication and private keys comply with the minimum length required by the underlying crypto algorithms. Perhaps the keys should be at least 8+ characters for any algorithm.



来源:https://stackoverflow.com/questions/52667806/snmpv3-getone-fails-while-trying-via-pysnmp-wrongvalueerror

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!