0

我有这个烦人的 M2Crypto 错误:

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
4

1 回答 1

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”是否确实存在于预期的路径中,并检查其读取权限。

于 2013-02-13T14:03:00.190 回答