etingof / pysnmp

Python SNMP library
http://snmplabs.com/pysnmp/
BSD 2-Clause "Simplified" License
576 stars 195 forks source link

Receiving V3 Traps - Engine ID #333

Open aryes opened 4 years ago

aryes commented 4 years ago

We used to work with PySNMP version 4.3.1 to receive SNMP V3 traps, and it worked perfectly. Recently, we upgraded to version 4.4.12, and the traps were not received anymore.

I debugged the issue and found that the call to __getUserInfo at service.py line 759 throws a NoSuchInstanceError exception:

        # 3.2.4
        try:
            (usmUserName,
             usmUserSecurityName,
             usmUserAuthProtocol,
             usmUserAuthKeyLocalized,
             usmUserPrivProtocol,
             usmUserPrivKeyLocalized) = self.__getUserInfo(
                snmpEngine.msgAndPduDsp.mibInstrumController,
                msgAuthoritativeEngineId, msgUserName
            )

I think it happens because the engine ID in the trap is not the same as the engine ID of the user I created for receiving the traps.

As far as I understand from the specs, we need to use the same engine ID for the receiving user and the trap sender.

If this is the case, why did it work in PySNMP version 4.3.1? Was it a bug in the library? Is engine ID matching not really mandatory?

lextm commented 1 year ago

The engine ID matching is mandatory as documented in the standard, so 4.3.1 indeed has a bug there and 4.4.12 contains the fix.