M2Crypto 加载 RSA 密钥失败
我遇到了一个烦人的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
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' 这个文件是否真的在预期的路径下,并且确认一下它的读取权限是否正确。