Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Django Q Bad Signature #544

Open
ropraet opened this issue Apr 29, 2021 · 11 comments
Open

Django Q Bad Signature #544

ropraet opened this issue Apr 29, 2021 · 11 comments

Comments

@ropraet
Copy link

ropraet commented Apr 29, 2021

Hello,

I updated the version from Django Q to the newest one, and suddenly I am getting:

Message: BadSignature('Signature "rQv3sSym58u1EYYibwMnKOgY43o" does not match',)
Arguments: ('Traceback (most recent call last):\n File "/usr/local/lib/python3.6/dist-packages/django_q/cluster.py", line 351, in pusher\n task = SignedPackage.loads(task[1])\n File "/usr/local/lib/python3.6/dist-packages/django_q/signing.py", line 26, in loads\n obj, key=Conf.SECRET_KEY, salt=Conf.PREFIX, serializer=PickleSerializer\n File "/usr/local/lib/python3.6/dist-packages/django_q/core_signing.py", line 40, in loads\n base64d = force_bytes(TimestampSigner(key, salt=salt).unsign(s, max_age=max_age))\n File "/usr/local/lib/python3.6/dist-packages/django_q/core_signing.py", line 75, in unsign\n result = super(TimestampSigner, self).unsign(value)\n File "/usr/local/lib/python3.6/dist-packages/django_q/core_signing.py", line 60, in unsign\n raise BadSignature('Signature "%s" does not match' % sig)\ndjango.core.signing.BadSignature: Signature "rQv3sSym58u1EYYibwMnKOgY43o" does not match\n',)

What is wrong here? Thanks!

@amo13
Copy link
Contributor

amo13 commented May 6, 2021

Seeing the same error now. Let me add the traceback I am getting:

May 06 16:19:17 archvm paperless-manage[4116]: --- Logging error ---
May 06 16:19:17 archvm paperless-manage[4116]: Traceback (most recent call last):
May 06 16:19:17 archvm paperless-manage[4116]:   File "/usr/lib/python3.9/site-packages/django_q/cluster.py", line 351, in pusher
May 06 16:19:17 archvm paperless-manage[4116]:     task = SignedPackage.loads(task[1])
May 06 16:19:17 archvm paperless-manage[4116]:   File "/usr/lib/python3.9/site-packages/django_q/signing.py", line 25, in loads
May 06 16:19:17 archvm paperless-manage[4116]:     return signing.loads(
May 06 16:19:17 archvm paperless-manage[4116]:   File "/usr/lib/python3.9/site-packages/django_q/core_signing.py", line 40, in loads
May 06 16:19:17 archvm paperless-manage[4116]:     base64d = force_bytes(TimestampSigner(key, salt=salt).unsign(s, max_age=max_age))
May 06 16:19:17 archvm paperless-manage[4116]:   File "/usr/lib/python3.9/site-packages/django_q/core_signing.py", line 75, in unsign
May 06 16:19:17 archvm paperless-manage[4116]:     result = super(TimestampSigner, self).unsign(value)
May 06 16:19:17 archvm paperless-manage[4116]:   File "/usr/lib/python3.9/site-packages/django_q/core_signing.py", line 60, in unsign
May 06 16:19:17 archvm paperless-manage[4116]:     raise BadSignature('Signature "%s" does not match' % sig)
May 06 16:19:17 archvm paperless-manage[4116]: django.core.signing.BadSignature: Signature "0H3NF72d4Veeh7JW_J_lyVw4sCj43Sx1e8s-diGx73w" does not match
May 06 16:19:17 archvm paperless-manage[4116]: During handling of the above exception, another exception occurred:
May 06 16:19:17 archvm paperless-manage[4116]: Traceback (most recent call last):
May 06 16:19:17 archvm paperless-manage[4116]:   File "/usr/lib/python3.9/logging/__init__.py", line 1083, in emit
May 06 16:19:17 archvm paperless-manage[4116]:     msg = self.format(record)
May 06 16:19:17 archvm paperless-manage[4116]:   File "/usr/lib/python3.9/logging/__init__.py", line 927, in format
May 06 16:19:17 archvm paperless-manage[4116]:     return fmt.format(record)
May 06 16:19:17 archvm paperless-manage[4116]:   File "/usr/lib/python3.9/logging/__init__.py", line 663, in format
May 06 16:19:17 archvm paperless-manage[4116]:     record.message = record.getMessage()
May 06 16:19:17 archvm paperless-manage[4116]:   File "/usr/lib/python3.9/logging/__init__.py", line 367, in getMessage
May 06 16:19:17 archvm paperless-manage[4116]:     msg = msg % self.args
May 06 16:19:17 archvm paperless-manage[4116]: TypeError: not all arguments converted during string formatting
May 06 16:19:17 archvm paperless-manage[4116]: Call stack:
May 06 16:19:17 archvm paperless-manage[4116]:   File "/usr/bin/paperless-manage", line 11, in <module>
May 06 16:19:17 archvm paperless-manage[4116]:     execute_from_command_line(sys.argv)
May 06 16:19:17 archvm paperless-manage[4116]:   File "/usr/lib/python3.9/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
May 06 16:19:17 archvm paperless-manage[4116]:     utility.execute()
May 06 16:19:17 archvm paperless-manage[4116]:   File "/usr/lib/python3.9/site-packages/django/core/management/__init__.py", line 413, in execute
May 06 16:19:17 archvm paperless-manage[4116]:     self.fetch_command(subcommand).run_from_argv(self.argv)
May 06 16:19:17 archvm paperless-manage[4116]:   File "/usr/lib/python3.9/site-packages/django/core/management/base.py", line 354, in run_from_argv
May 06 16:19:17 archvm paperless-manage[4116]:     self.execute(*args, **cmd_options)
May 06 16:19:17 archvm paperless-manage[4116]:   File "/usr/lib/python3.9/site-packages/django/core/management/base.py", line 398, in execute
May 06 16:19:17 archvm paperless-manage[4116]:     output = self.handle(*args, **options)
May 06 16:19:17 archvm paperless-manage[4116]:   File "/usr/lib/python3.9/site-packages/django_q/management/commands/qcluster.py", line 22, in handle
May 06 16:19:17 archvm paperless-manage[4116]:     q.start()
May 06 16:19:17 archvm paperless-manage[4116]:   File "/usr/lib/python3.9/site-packages/django_q/cluster.py", line 75, in start
May 06 16:19:17 archvm paperless-manage[4116]:     self.sentinel.start()
May 06 16:19:17 archvm paperless-manage[4116]:   File "/usr/lib/python3.9/multiprocessing/process.py", line 121, in start
May 06 16:19:17 archvm paperless-manage[4116]:     self._popen = self._Popen(self)
May 06 16:19:17 archvm paperless-manage[4116]:   File "/usr/lib/python3.9/multiprocessing/context.py", line 224, in _Popen
May 06 16:19:17 archvm paperless-manage[4116]:     return _default_context.get_context().Process._Popen(process_obj)
May 06 16:19:17 archvm paperless-manage[4116]:   File "/usr/lib/python3.9/multiprocessing/context.py", line 277, in _Popen
May 06 16:19:17 archvm paperless-manage[4116]:     return Popen(process_obj)
May 06 16:19:17 archvm paperless-manage[4116]:   File "/usr/lib/python3.9/multiprocessing/popen_fork.py", line 19, in __init__
May 06 16:19:17 archvm paperless-manage[4116]:     self._launch(process_obj)
May 06 16:19:17 archvm paperless-manage[4116]:   File "/usr/lib/python3.9/multiprocessing/popen_fork.py", line 71, in _launch
May 06 16:19:17 archvm paperless-manage[4116]:     code = process_obj._bootstrap(parent_sentinel=child_r)
May 06 16:19:17 archvm paperless-manage[4116]:   File "/usr/lib/python3.9/multiprocessing/process.py", line 315, in _bootstrap
May 06 16:19:17 archvm paperless-manage[4116]:     self.run()
May 06 16:19:17 archvm paperless-manage[4116]:   File "/usr/lib/python3.9/multiprocessing/process.py", line 108, in run
May 06 16:19:17 archvm paperless-manage[4116]:     self._target(*self._args, **self._kwargs)
May 06 16:19:17 archvm paperless-manage[4116]:   File "/usr/lib/python3.9/site-packages/django_q/cluster.py", line 165, in __init__
May 06 16:19:17 archvm paperless-manage[4116]:     self.start()
May 06 16:19:17 archvm paperless-manage[4116]:   File "/usr/lib/python3.9/site-packages/django_q/cluster.py", line 169, in start
May 06 16:19:17 archvm paperless-manage[4116]:     self.spawn_cluster()
May 06 16:19:17 archvm paperless-manage[4116]:   File "/usr/lib/python3.9/site-packages/django_q/cluster.py", line 243, in spawn_cluster
May 06 16:19:17 archvm paperless-manage[4116]:     self.pusher = self.spawn_pusher()
May 06 16:19:17 archvm paperless-manage[4116]:   File "/usr/lib/python3.9/site-packages/django_q/cluster.py", line 198, in spawn_pusher
May 06 16:19:17 archvm paperless-manage[4116]:     return self.spawn_process(pusher, self.task_queue, self.event_out, self.broker)
May 06 16:19:17 archvm paperless-manage[4116]:   File "/usr/lib/python3.9/site-packages/django_q/cluster.py", line 194, in spawn_process
May 06 16:19:17 archvm paperless-manage[4116]:     p.start()
May 06 16:19:17 archvm paperless-manage[4116]:   File "/usr/lib/python3.9/multiprocessing/process.py", line 121, in start
May 06 16:19:17 archvm paperless-manage[4116]:     self._popen = self._Popen(self)
May 06 16:19:17 archvm paperless-manage[4116]:   File "/usr/lib/python3.9/multiprocessing/context.py", line 224, in _Popen
May 06 16:19:17 archvm paperless-manage[4116]:     return _default_context.get_context().Process._Popen(process_obj)
May 06 16:19:17 archvm paperless-manage[4116]:   File "/usr/lib/python3.9/multiprocessing/context.py", line 277, in _Popen
May 06 16:19:17 archvm paperless-manage[4116]:     return Popen(process_obj)
May 06 16:19:17 archvm paperless-manage[4116]:   File "/usr/lib/python3.9/multiprocessing/popen_fork.py", line 19, in __init__
May 06 16:19:17 archvm paperless-manage[4116]:     self._launch(process_obj)
May 06 16:19:17 archvm paperless-manage[4116]:   File "/usr/lib/python3.9/multiprocessing/popen_fork.py", line 71, in _launch
May 06 16:19:17 archvm paperless-manage[4116]:     code = process_obj._bootstrap(parent_sentinel=child_r)
May 06 16:19:17 archvm paperless-manage[4116]:   File "/usr/lib/python3.9/multiprocessing/process.py", line 315, in _bootstrap
May 06 16:19:17 archvm paperless-manage[4116]:     self.run()
May 06 16:19:17 archvm paperless-manage[4116]:   File "/usr/lib/python3.9/multiprocessing/process.py", line 108, in run
May 06 16:19:17 archvm paperless-manage[4116]:     self._target(*self._args, **self._kwargs)
May 06 16:19:17 archvm paperless-manage[4116]:   File "/usr/lib/python3.9/site-packages/django_q/cluster.py", line 353, in pusher
May 06 16:19:17 archvm paperless-manage[4116]:     logger.error(e, traceback.format_exc())
May 06 16:19:17 archvm paperless-manage[4116]: Message: BadSignature('Signature "0H3NF72d4Veeh7JW_J_lyVw4sCj43Sx1e8s-diGx73w" does not match')
May 06 16:19:17 archvm paperless-manage[4116]: Arguments: ('Traceback (most recent call last):\n  File "/usr/lib/python3.9/site-packages/django_q/cluster.py", line 351, in pusher\n    task = SignedPackage.loads(task[1])\n  File "/usr/lib/python3.9/site-packages/django_q/signing.py", line 25, in loads\n    return signing.loads(\n  File "/usr/lib/python3.9/site-packages/django_q/core_signing.py", line 40, in loads\n    base64d = force_bytes(TimestampSigner(key, salt=salt).unsign(s, max_age=max_age))\n  File "/usr/lib/python3.9/site-packages/django_q/core_signing.py", line 75, in unsign\n    result = super(TimestampSigner, self).unsign(value)\n  File "/usr/lib/python3.9/site-packages/django_q/core_signing.py", line 60, in unsign\n    raise BadSignature(\'Signature "%s" does not match\' % sig)\ndjango.core.signing.BadSignature: Signature "0H3NF72d4Veeh7JW_J_lyVw4sCj43Sx1e8s-diGx73w" does not match\n',)

@tboulogne
Copy link

@ropraet @amo13

Hello,

I change the secret key with one generate like this :

python -c "import secrets; print(secrets.token_urlsafe())"

tips from : georgemarshall/django-cryptography#33 (comment)

Works for me.

Best,

@amo13
Copy link
Contributor

amo13 commented Jul 31, 2021

Oh, forgot about this one.
For me, the issue is resolved: I didn't notice that I was feeding a wrong configuration file to my django app (precedence was unexpectedly taken by another file than the one I thought). Feeding the right config file to the application solved the bad signature issue of which I pasted my logs above.

@luk8475
Copy link

luk8475 commented Sep 21, 2021

I am getting same issue when trying to run async_task
File "/usr/local/lib/python3.7/site-packages/django_q/tasks.py", line 71, in async_task return _sync(pack) File "/usr/local/lib/python3.7/site-packages/django_q/tasks.py", line 762, in _sync task = SignedPackage.loads(pack) File "/usr/local/lib/python3.7/site-packages/django_q/signing.py", line 26, in loads obj, key=Conf.SECRET_KEY, salt=Conf.PREFIX, serializer=PickleSerializer File "/usr/local/lib/python3.7/site-packages/django_q/core_signing.py", line 35, in loads base64d = force_bytes(TimestampSigner(key, salt=salt).unsign(s, max_age=max_age)) File "/usr/local/lib/python3.7/site-packages/django_q/core_signing.py", line 70, in unsign result = super(TimestampSigner, self).unsign(value) File "/usr/local/lib/python3.7/site-packages/django_q/core_signing.py", line 55, in unsign raise BadSignature('Signature "%s" does not match' % sig) django.core.signing.BadSignature: Signature "GWJCifsA-4w2KiT8yKQVx-GY0HE" does not match

The solution to update SECRET_KEY did not work for me

@tboulogne
Copy link

@luk8475 did you generate a safe url SECRET_KEY ?

@luk8475
Copy link

luk8475 commented Sep 21, 2021

@tboulogne Yes, I ran python -c "import secrets; print(secrets.token_urlsafe())" and updated my settings, but it did not work

@daviddavis83
Copy link

I am having the same issue when using async_task.

@samdixonbrown
Copy link

I'm also having the same issue and token_urlsafe() doesn't seem to help

@amo13
Copy link
Contributor

amo13 commented Oct 27, 2022

This project is abandoned. Last commit is more than a year ago.

@samdixonbrown
Copy link

@amo13 Ok thanks. When you said:

Oh, forgot about this one. For me, the issue is resolved: I didn't notice that I was feeding a wrong configuration file to my django app (precedence was unexpectedly taken by another file than the one I thought). Feeding the right config file to the application solved the bad signature issue of which I pasted my logs above.

By "feeding a wrong configuration file" you mean your settings.py?

@amo13
Copy link
Contributor

amo13 commented Oct 27, 2022

That was with paperless. There are 3 locations on the filesystem where you can place the paperless.conf configuration file. I placed it under /etc/paperless.conf. When launching paperless, it looks under ./paperless.conf first before looking at /etc/paperless.conf if the first one does not exist. After upgrading paperless, a template configuration file is placed in the first location, taking precedence over my real configuration file, which in turn is not read at all. This is what caused the Bad Signature error for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants