2

我在 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有问题吗?

4

2 回答 2

1

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

于 2013-08-28T15:46:57.690 回答
0

我有同样的问题,我猜是因为无法加载相应的证书。下面是加载证书的 httplib2/ init .py的代码片段。

    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 解决了这个问题

于 2013-09-26T12:36:12.277 回答