OpenSIPS / opensips-cli

OpenSIPS CLI tool - an interactive command line tool that can be used to control and monitor OpenSIPS servers.
GNU General Public License v3.0
86 stars 48 forks source link

opensips-cli add user failed, unsupported hash type sha512-256 #109

Closed fangang1989 closed 11 months ago

fangang1989 commented 1 year ago

when i add a new user by opensips-cli , but it can not add successfully, and more info as follows:

[root@vmsOMiFfWXtutLxt3b opensips]# opensips-cli -x user add fg001@test.com fg001 DEBUG: fifo file /tmp/opensips_fifo does not exist! DEBUG: Loaded module 'user' DEBUG: running in non-interactive mode user add ['fg001@test.com', 'fg001'] DEBUG: running command 'add' '['fg001@test.com', 'fg001']' DEBUG: connecting to mysql://opensips:opensipsrw@localhost Traceback (most recent call last): File "/usr/lib64/python3.6/hashlib.py", line 178, in __hash_new name, data, usedforsecurity=usedforsecurity) ValueError: unsupported hash type sha512-256

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/bin/opensips-cli", line 9, in run_console() File "/usr/bin/opensips-cli", line 6, in run_console main.main() File "/usr/lib/python3.6/site-packages/opensipscli/main.py", line 78, in main sys.exit(shell.cmdloop()) File "/usr/lib/python3.6/site-packages/opensipscli/cli.py", line 247, in cmdloop ret = self.run_command(module, command, modifiers, params) File "/usr/lib/python3.6/site-packages/opensipscli/cli.py", line 409, in run_command return mod[0].invoke(cmd, params, modifiers) File "/usr/lib/python3.6/site-packages/opensipscli/module.py", line 36, in invoke return f(params, modifiers) File "/usr/lib/python3.6/site-packages/opensipscli/modules/user.py", line 168, in do_add self.user_get_ha1_sha512t256(username, domain, password) File "/usr/lib/python3.6/site-packages/opensipscli/modules/user.py", line 119, in user_get_ha1_sha512t256 o = hashlib.new("sha512-256") File "/usr/lib64/python3.6/hashlib.py", line 189, in __hash_new return get_builtin_constructor(name)(data, **kwargs) File "/usr/lib64/python3.6/hashlib.py", line 120, in get_builtin_constructor raise ValueError('unsupported hash type ' + name) ValueError: unsupported hash type sha512-256

my computer info is: os version: CentOS 7.9 python version:3.6.8 opensips-cli vesion: 0.2.0

please help me ,how to solve the problme? thanks.

gao114882 commented 1 year ago

this issue i met, update python to 3.9.18

liviuchircu commented 11 months ago

Hey, @gao114882! If you still have that CentOS 7.9 system available, can you let me know the OpenSSL version you used to reproduce the issue?

I'm asking because, according to OpenSSL 1.1.1 release notes, that's the point in time where the SHA-512-256 digest was introduced, and I am fairly confident the cryptography Python suite simply makes use of OpenSSL, rather than reinventing the wheel.

So if your CentOS has a 1.1.0i or older OpenSSL, it's the direct reason for the exception!

Meanwhile, I will push a small fix so the CLI prints an error in this case, and just leaves your hash field blank. If you need that secured RFC 8760 hash, then you should upgrade your stuff! 😊

liviuchircu commented 11 months ago

PS: I just realized CentOS 7.9 is not the new generation of "CentOS Stream" (that starts at 8, now at 9). So we're talking about a vanilla CentOS, which we can reasonably expect to have an older than 1.1.1 OpenSSL too!

liviuchircu commented 11 months ago

Added handling for this exception in e3ec055f15a.