2013-03-29 82 views
8

我想使用Google的Oauth連接到谷歌AdSense,並得到這個錯誤。 任何解決它的線索?SSL拋出錯誤185090050雖然通過Oauth身份驗證

任何人在python中遇到過這樣的問題?

Traceback (most recent call last): 
    File "get_all_saved_reports.py", line 56, in <module> 
     main(sys.argv) 
    File "get_all_saved_reports.py", line 36, in main 
     service = sample_utils.initialize_service() 
    File "/home/nish/Programs/python/google-adsense/samples/adsense/sample_utils.py", line 114, in initialize_service 
     credentials = prepare_credentials() 
    File "/home/nish/Programs/python/google-adsense/samples/adsense/sample_utils.py", line 95, in prepare_credentials 
     credentials = run(FLOW, storage) 
     File "/usr/local/lib/python2.7/dist-packages/oauth2client-1.1-py2.7.egg/oauth2client/util.py", line 128, in positional_wrapper 
     return wrapped(*args, **kwargs) 
     File "/usr/local/lib/python2.7/dist-packages/oauth2client-1.1-py2.7.egg/oauth2client/tools.py", line 197, in run 
     credential = flow.step2_exchange(code, http=http) 
     File "/usr/local/lib/python2.7/dist-packages/oauth2client-1.1-py2.7.egg/oauth2client/util.py", line 128, in positional_wrapper 
     return wrapped(*args, **kwargs) 
     File "/usr/local/lib/python2.7/dist-packages/oauth2client-1.1-py2.7.egg/oauth2client/client.py", line 1283, in step2_exchange 
     headers=headers) 
     File "/usr/local/lib/python2.7/dist-packages/httplib2-0.8-py2.7.egg/httplib2/__init__.py", line 1571, 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-0.8-py2.7.egg/httplib2/__init__.py", line 1318, in _request 
     (response, content) = self._conn_request(conn, request_uri, method, body, headers) 
     File "/usr/local/lib/python2.7/dist-packages/httplib2-0.8-py2.7.egg/httplib2/__init__.py", line 1253, in _conn_request 
     conn.connect() 
     File "/usr/local/lib/python2.7/dist-packages/httplib2-0.8-py2.7.egg/httplib2/__init__.py", line 1022, in connect 
     self.disable_ssl_certificate_validation, self.ca_certs) 
     File "/usr/local/lib/python2.7/dist-packages/httplib2-0.8-py2.7.egg/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 
+0

你可能想檢查這個線程:https://github.com/kennethreitz/requests/issues/557 –

+0

我發佈之前,我看着它。它沒有幫助我 – Nish

回答

30

我與Python 2.7.5中獲得的OAuth2(Twitter的API,而不是谷歌)這個確切X509錯誤和使用阿克沙伊腐爛的意見,並改變了cacerts.txt的權限與

chmod 644 /usr/local/lib/python2.7/dist-packages/httplib2-0.8-py2.7.egg/httplib2/cacerts.txt 

那固定的問題,我現在可以像普通用戶一樣運行我的模塊,而不是將其安裝。 謝謝!

+4

在Yosemite(10.10.1)中,取決於您的Python版本,該文件位於/Library/Python/2.7/site-packages/httplib2-0.9-py2.7.egg/httplib2/cacerts.txt –

+0

爲我工作像一個魅力!謝謝 – Simon

0

我想出瞭解決方案。 谷歌OAuth是瘋狂理解,我不得不第一次運行腳本作爲sudo/root。這工作。還要確保權限設置正確。

+0

你能詳細說明嗎?我遇到同樣的問題 –

+0

請確保您擁有執行權限。 – Nish

+0

不那麼簡單。我一直很樂意作爲普通用戶授權,然後遇到這個問題,sudoing不能解決問題。 –

7

此問題在加載證書文件時發生。如果以root用戶身份運行該程序,則會解決此問題。 或者您可以檢查文件的權限:/usr/local/lib/python2.7/dist-packages/httplib2-0.8-py2.7.egg/httplib2/cacerts.txt,併爲此文件提供必要的權限。

1

在我的情況下,我運行的是Django開發服務器。如果在切換到虛擬環境之前運行服務器,我發現[Errno 185090050] _ssl.c:345:錯誤:0B084002:x509證書例程:X509_load_cert_crl_file:我的回溯中的系統庫。簡而言之,我不再運行創建證書的httplib2版本:我可能運行dist-package。 (Ububtu 13.10),Python 2.7,Django 1.62。希望這有助於他人。