【发布时间】:2017-01-23 19:27:09
【问题描述】:
我在使用pyelliptic(下面给出的版本)时遇到上述错误。
触发它的python代码:
print("Salt: %s" % salt)
server_key = pyelliptic.ECC(curve="prime256v1") # ----->> Line2
print("Server_key: %s" % server_key) # ----->> Line3
server_key_id = base64.urlsafe_b64encode(server_key.get_pubkey()[1:])
"Salt: ..." 消息显示正常,错误在 pyelliptic.ECC() 调用中。
追溯:
File "/usr/local/lib/python2.7/dist-packages/pyelliptic/ecc.py", line 89, in __init__
self.privkey, self.pubkey_x, self.pubkey_y = self._generate()
File "/usr/local/lib/python2.7/dist-packages/pyelliptic/ecc.py", line 231, in _generate
raise Exception("[OpenSSL] EC_KEY_generate_key FAIL ... " + OpenSSL.get_error())
我得到的错误是(第二个可能相关也可能不相关):
-
Exception('[OpenSSL] EC_KEY_generate_key FAIL ... error:00000000:lib(0):func(0):reason(0)',)(参考文件链接:https://github.com/yann2192/pyelliptic/blob/master/pyelliptic/ecc.py#L214) extern "Python": function Cryptography_rand_bytes() called, but @ffi.def_extern() was not called in the current subinterpreter. Returning 0.
Requirements.txt(部分):
setuptools==27.1.2
cryptography==1.5
pyelliptic==1.5.7
pyOpenSSL==16.1.0
https://github.com/yann2192/pyelliptic/issues/39 表示pyelliptic v1.5.7 与旧版本存在一些问题(不确定这是否适用于此处)。
其他详情:
Python 版本:2.7。
仅在 Google Compute Engine VM 实例上出现此错误。
在本地开发服务器上运行良好。 在 python shell 中也能正常工作 Google Compute Engine VM。
(问题是'EntryPoint' object has no attribute 'resolve' when using Google Compute Engine的后续,讨论可能有用)
【问题讨论】:
-
好的,我们开始吧。你说你得到一个异常,但代码并没有停止?是否执行了以下行 (
print("Server_key:<...>)?如果“错误”实际上是 Django 错误日志条目,here's how you include a stacktrace into it. -
代码停在 Line2 本身。 Line3 根本不执行。 (实际上有时,可能 10 次中有 1 次,这段代码执行得非常好,完全没有任何错误)
-
这意味着第二个错误是由一些不相关的代码块产生的(它可能是也可能不是第一个的结果),因此堆栈跟踪在这里最有帮助。
-
解决第一个错误的最简单方法是在
pdb下运行整个 Django,在故障线路上中断并调查发生了什么。只有你能做到;但我会尝试在此处重现该问题。 -
我不确定如何在 pdb 下运行整个 django,因为代码是从浏览器的“执行”按钮执行的。此外,这个问题似乎不是因为 Python 代码。这似乎是与 pyelliptic 库和其他一些相关软件包有关的问题。
标签: python django google-compute-engine