M2Crypto加载RSA密钥失败

时间:2013-02-13 13:49:24

标签: python m2crypto

我有这个恼人的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

1 个答案:

答案 0 :(得分: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'是否确实存在于预期的路径中,并检查其读取权限。