【问题标题】:SSLError when using google api client library使用 google api 客户端库时出现 SSLError
【发布时间】:2015-03-17 04:03:54
【问题描述】:

我在 Ubuntu 服务器上使用 google api 客户端库。虽然该脚本在我自己的机器上运行良好,但在服务器上却因 SSLError 而失败:

File "/home/default/bigbluebutton/youtube/uploader/uploadvideo.py", line 78, in authorize
    credentials = flow.step2_exchange(code)        
  File "/usr/local/lib/python2.7/dist-packages/oauth2client/util.py", line 132, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/oauth2client/client.py", line 1283, in step2_exchange
    headers=headers)
  File "/usr/local/lib/python2.7/dist-packages/httplib2/__init__.py", line 1570, in request
    (response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
  File "/usr/local/lib/python2.7/dist-packages/httplib2/__init__.py", line 1317, in _request
    (response, content) = self._conn_request(conn, request_uri, method, body, headers)
  File "/usr/local/lib/python2.7/dist-packages/httplib2/__init__.py", line 1252, in _conn_request
    conn.connect()
  File "/usr/local/lib/python2.7/dist-packages/httplib2/__init__.py", line 1021, in connect
    self.disable_ssl_certificate_validation, self.ca_certs)
  File "/usr/local/lib/python2.7/dist-packages/httplib2/__init__.py", line 80, in _ssl_wrap_socket
    cert_reqs=cert_reqs, ca_certs=ca_certs)
  File "/usr/lib/python2.7/ssl.py", line 381, in wrap_socket
    ciphers=ciphers)
  File "/usr/lib/python2.7/ssl.py", line 141, in __init__
    ciphers)
ssl.SSLError: [Errno 185090050] _ssl.c:340: error:0B084002:x509 certificate routines:X509_load_cert_crl_file:system lib

如何解决这个问题? SSL 有问题吗?

【问题讨论】:

  • 这里的信息可能会对您有所帮助:github.com/kennethreitz/requests/issues/557
  • 我试过了,但没有帮助。服务器是Ubuntu 12.04,和m开发机一样。
  • 您尝试了该链接中的哪些解决方案?

标签: python google-api-python-client


【解决方案1】:

对我有用的解决方案是将 cacerts.txt 的权限更改为您自己的用户(而不是 root)。或者以root身份运行。您可以在 /usr/local/lib/python2.7/dist-packages/httplib2/cacerts.txt 找到这些文件

【讨论】:

    【解决方案2】:

    我有同样的问题,我猜是因为无法加载相应的证书。 下面是来自 httplib2/init.py 的代码 sn-p,用于加载证书。

        try:
            # Users can optionally provide a module that tells us where the CA_CERTS
            # are located.
            import ca_certs_locater
            CA_CERTS = ca_certs_locater.get()
        except ImportError:
            # Default CA certificates file bundled with httplib2.
            CA_CERTS = os.path.join(
                os.path.dirname(os.path.abspath(__file__ )), "cacerts.txt")
    

    httplib2/init.py 位置:/usr/local/lib/python2.7/dist-packages/httplib2-0.8-py2.7.egg/httplib2/init强>.py

    在上面的代码中,ca_certs_locater 从基本操作系统加载证书授权文件,而不是 httplib2 包中的文件。 如果ca_certs_locater 模块不存在,它会从文件 cacerts.txt 加载证书。

    在我的情况下,模块不存在,所以它是从文件“cacerts.txt”加载的,我不确定它是否存在。我通过安装模块解决了这个问题,ca_certs_locater

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-17
      • 1970-01-01
      • 2019-06-09
      • 1970-01-01
      相关资源
      最近更新 更多