puresnmp icon indicating copy to clipboard operation
puresnmp copied to clipboard

V3 support out of the box, identifier 3?

Open srdjus opened this issue 8 months ago • 1 comments

I'm using Python 3.12 and I Installed puresnmp w/ puresnmp-crypto package. I already have V2 implementation and puresnmp is working as expected.

This is what I get when I try to run a get command on my SNMP v3 agent:

Got an exception: Namespace 'puresnmp_plugins.security' did not contain a plugin with identifier 3. Known identifiers: [0, 1, 2]. See the 'puresnmp' documentation on plugins.

I tried snmpwalk/snmpget from CLI, and it works. I am not sure if there is something else I have to configure in order to use V3? How do I include this identifier and where?

import asyncio
from puresnmp import PyWrapper, Client, V3
from puresnmp.credentials import Auth, Priv
 
credentials = V3(
    username="bootstrap",
    auth=Auth(b"temp_password", "md5"),
    priv=Priv(b"myprivphrase", "aes")
)

# Create a new client
client = PyWrapper(
    Client(
        ip="127.0.0.1",
        port=161,
        credentials=credentials
    )
)

try:
     output = await client.get("1.3.6.1.2.1.1.5.0")
     print(f"Sys name is: {output}")
except Exception as e:
     print(f"Got an exception: {e}")

UPDATE: I solved it. I had to install typing-extensions package.

In puresnmp/plugins/pluginbase.py discover_plugins function 'puresnmp_plugins.security' module couldn't be found, ImportError was caught telling me I'm missing this package.

UPDATE 2: Now I got like 10 new errors like puresnmp_plugins.security.usm.EncryptionError: Unable to encrypt message (string argument without an encoding) not sure if this is related, but I guess it has something to do with python/packages version/dependencies...

srdjus avatar Jun 13 '24 08:06 srdjus