def __new__(typ, value):
if isinstance(value, basestring):
path = process.config_file(value)
if path is None:
log.warn("Private key file '%s' is not readable" % value)
return None
try:
f = open(path, 'rt')
except:
log.warn("Private key file '%s' could not be open" % value)
return None
try:
try:
return crypto.load_privatekey(crypto.FILETYPE_PEM, f.read())
except crypto.Error, e:
log.warn("Private key file '%s' could not be loaded: %s" % (value, str(e)))
return None
finally:
f.close()
else:
raise TypeError, 'value should be a string'
评论列表
文章目录