我正在运行ff。从在Mac OS X(优胜美地)一个的virtualenv代码:如何在Facebook图形API上使用twisted.web.client.Agent时处理OpenSSL.SSL.Error?
# testfb.py
from twisted.internet import reactor
from twisted.python import log
from twisted.web.client import Agent
GRAPH_API = "https://graph.facebook.com/v2.5"
def stop(_):
reactor.stop()
def get_me(access_token):
agent = Agent(reactor)
uri = "{}/me?access_token={}".format(GRAPH_API, access_token)
log.msg("uri:" + uri)
return agent.request("GET", uri)
if __name__ == "__main__":
import sys
access_token = sys.argv[1]
d = get_me(access_token)
d.addErrback(log.err)
d.addCallback(stop)
reactor.run()
我也得到:
Failure: twisted.web._newclient.ResponseNeverReceived: [<twisted.python.failure.Failure OpenSSL.SSL.Error: [('SSL routines', 'SSL3_GET_SERVER_CERTIFICATE', 'certificate verify failed')]>]
当我打电话的URI的卷曲我没有这个问题。
顺便说一句,我还在virtualenv上使用pip安装了service_identity。
我正在使用macports,我尝试了几次重新安装openssl和py27-pyopenssl,但没有运气。 'certifi',OTOH,为我工作。谢谢! – kerrigangster
我说“自制”,而不是“macports”的目的:)。证书颁发机构提取代码特定于自制软件,而不是与OpenSSL相关的。 https://github.com/Homebrew/homebrew/blob/master/Library/Formula/openssl.rb#L113这就是为什么我列出certifi作为替代选项:)。 – Glyph
很高兴我可以帮忙,但! – Glyph