2016-09-15 217 views
0

我在使用pyelliptic時收到上述錯誤)。pyelliptic.ECC()上的「OpenSSL:EC_KEY_generate_key失敗...錯誤:00000000:lib(0):func(0):reason(0)」

觸發它的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()) 

錯誤(S)我得到的是(注:第二個可能會或可能不相關):

  1. 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
  2. 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/39pyellipticv1.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後續的討論有可能是使用的)

+0

好的,我們走吧。你說你得到一個異常,但代碼不會停止?是否執行了下列代碼行('print(「Server_key:<...>'))?如果」error「實際上是一個Django錯誤日誌條目,[這裏是如何包含一個堆棧跟蹤到它](http://stackoverflow.com/questions/) 5886275/print-a-stack-trace-to-stdout-on-errors-in-django-while-using-manage-py-runserve) –

+0

代碼停在Line2本身,Line3根本不被執行(實際上有時候,可能是10次中的1次,這段代碼執行得非常好,沒有任何錯誤) – Naveen

+0

這意味着第二個錯誤是由一些不相關的代碼塊產生的(它可能會或可能不是第一個的結果),所以堆棧跟蹤在這裏最有幫助 –

回答

0

剛剛添加的以下內容:WSGIApplicationGroup %{GLOBAL}

/etc/apache2/sites-available/default-ssl.conf文件和所有這些錯誤得到解決。

+0

然後相關:http://stackoverflow.com/questions/755070/what-is-the-purpose-of-the-sub-interpreter-api-in-cpython –

+0

沒有得到你想要傳達的究竟是什麼?如果可能,你可以用簡單的術語解釋一下嗎? :P – Naveen

+0

你給出的代碼[讓代碼在主解釋器實例中運行](http://modwsgi.readthedocs.io/en/develop/configuration-directives/WSGIApplicationGroup.html)。這意味着根本原因是pyelliptic與CPython的子解析器體系結構不兼容(這並不意味着它不好,CPython功能目前相當不完整,甚至實際上沒有文檔)。這裏的要點是,這個解決方案也可以應用於其他許多C擴展。 –

相關問題