2013-08-26 44 views
2

我在Ubuntu服務器上使用谷歌API客戶端庫。當腳本作品在我自己的機器上正常,服務器上的失敗與SSLError:SSLError當使用谷歌API客戶端庫

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有什麼問題嗎?

+1

這裏的信息可能會幫助你:https://github.com/kennethreitz/requests/issues/557 –

+0

我試過了,但它沒有幫助。服務器是Ubuntu 12.04,與m開發機器相同。 –

+0

你嘗試過什麼解決方案? –

回答

1

解決方案適用於我的是將cacerts.txt的權限更改爲您自己的用戶(而不是root用戶)。或者以root身份運行。你可以在/usr/local/lib/python2.7/dist-packages/httplib2/cacerts.txt找到這些文件。

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/初始化的.py地點:/usr/local/lib/python2.7/dist-packages/httplib2-0.8-py2.7.egg/httplib2/ 初始化的.py

在上面的代碼中,ca_certs_locater從基本操作系統加載證書頒發機構文件,而不是httplib2包中的證書頒發機構文件。 如果ca_certs_locater模塊不存在,它將從文件cacerts.txt中加載證書。

在我的情況下,模塊不存在,所以它從文件「cacerts.txt」加載,我不確定是否存在或不存在。我通過安裝模塊ca_certs_locater來解決此問題。

相關問題