我试图把一些python对象主要是json序列化除了datem.dtimetime在rabbitmq队列中,所以使用pickle来序列化.
celery_config文件:
CELERY_TASK_SERIALIZER = 'pickle' CELERY_RESULT_SERIALIZER = 'pickle'
这是一个例外,说:
File "/usr/local/lib/python2.7/dist-packages/kombu/serialization.py", line 174, in loads raise self._for_untrusted_content(content_type, 'untrusted') ContentDisallowed: Refusing to deserialize untrusted content of type pickle (application/x-python-serialize)
这个链接 建议我做消息签名,我不知道哪些.
有人可以指导我如何解决它?
你尝试过,这个:
CELERY_ACCEPT_CONTENT = ['pickle']
如此链接(http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-accept_content)所示,此设置接受序列化程序名称和内容类型的列表,因此您可以选择白色列出序列化程序或您希望序列化的内容类型.
所以要么执行上述操作,要么使用SSL消息签名...这基本上是构建一个ssh-key对,并允许celery
使用您的密钥来获得安全连接.
您可以通过注册"KEY"和"CERTIFICATE"来激活邮件签名:
CELERY_SECURITY_KEY = '/etc/ssl/private/worker.key' CELERY_SECURITY_CERTIFICATE = '/etc/ssl/certs/worker.pem' CELERY_SECURITY_CERT_STORE = '/etc/ssl/certs/*.pem' from celery.security import setup_security setup_security()
至于那些东西是什么意思......以及它是如何工作的,请参阅:http: //www.tldp.org/HOWTO/SSL-Certificates-HOWTO/x64.html
此外,对于如何生成密钥(并启用安全的无密码登录),请参阅: https://help.github.com/articles/generating-ssh-keys/ 或http://mah.everybody.org/docs/ssh为其中引用的更一般的链接.