Skip to main content
 首页 » 编程设计

python之使用 google api 客户端库时出现 SSLError

2025年05月04日11开发

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

请您参考如下方法:

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