2013-02-13 102 views
0

我有這個惱人的M2Crypto錯誤:M2Crypto加載RSA密鑰失敗

In [126]: M2Crypto.EVP.load_key('private-key-2048.pem', 'r') 
--------------------------------------------------------------------------- 
BIOError         Traceback (most recent call last) 
/<DJANGOPATH>/django/core/management/commands/shell.pyc in <module>() 
----> 1 M2Crypto.EVP.load_key('private-key-2048.pem', 'r') 

/var/www/.../lib/python2.6/site-packages/M2Crypto-0.21.1-py2.6-linux-x86_64.egg/M2Crypto/EVP.py in load_key(file, callback) 
    364  bio = m2.bio_new_file(file, 'r') 
    365  if bio is None: 
--> 366   raise BIO.BIOError(Err.get_error()) 
    367  cptr = m2.pkey_read_pem(bio, callback) 
    368  m2.bio_free(bio) 

BIOError: 47625728188304:error:0200100E:system library:fopen:Bad address:bss_file.c:122:fopen('','r') 
47625728188304:error:2006D002:BIO routines:BIO_new_file:system lib:bss_file.c:127: 

更新:

-rw-rw-r-- 1 user group 1675 Feb 13 08:27 private-key-2048.pem 

回答

0
364  bio = m2.bio_new_file(file, 'r') 
    365  if bio is None: 
--> 366   raise BIO.BIOError(Err.get_error()) 

bio_new_file方法返回None如果傳遞文件名/對象水溼打開。

我會檢查'private-key-2048.pem'是否確實存在於預期的路徑中,並檢查其讀取權限。

+0

是的,它存在,看到更新的問題... – patroqueeet 2013-02-13 14:13:18

+0

django外殼正在尋找的路徑中的'private-key-2048.pem'?你能指定像'/ home/user/certs/private-key-2048.pem'這樣的完整路徑並將它傳遞給進行加載的模塊嗎? – 2013-02-13 18:27:42

+0

是的。問題是'fopen(''...')。 – patroqueeet 2013-02-13 20:12:56