2017-09-16 97 views
1

我對cert的工作方式並不太熟悉,所以我可能在做一些愚蠢的事情,提前道歉。Python請求Tableau REST API SSL錯誤

我試圖與畫面的其餘API進行交互,並使用安全連接,因爲他們的一些電話需要這樣做。

但是,我遇到了各種錯誤創建連接。

我能夠創建一個不安全的連接:

requests.get('https://tableau.mynetwork.lan', verify = False) 
<Response [200]> 

我也能夠創造與谷歌的安全連接:

requests.get('https://google.com', verify = True) 
<Response [200]> 

但是,試圖創建我的畫面的安全連接服務器:

requests.get('https://tableau.mynetwork.lan', verify = True) 

或者:

requests.get('https://tableau.mynetwork.lan', verify = certifi.old_where()) 

導致以下錯誤:

SSLError: ("bad handshake: Error([('SSL routines', 'ssl3_get_server_certificate', 'certificate verify failed')],)",) 

我有我的本地計算機上我的畫面服務器證書,並試圖通過證書參數來傳遞他們:

tableau_cert = r"C:\tabcert.cer" 
requests.get('https://tableau.mynetwork.lan', cert=tableau_cert, verify = True) 

但得到這個錯誤:

Error: [('PEM routines', 'PEM_read_bio', 'no start line'), ('SSL routines', 'SSL_CTX_use_certificate_file', 'PEM lib')] 

任何人有任何指針?

回答

1

I have my tableau server certs on my local machine, and have attempted to pass them via the cert parameter:

requests.get('https://tableau.mynetwork.lan', cert=tableau_cert, verify = True) 

cert是指定CA的錯誤參數。正確的方法是according to the documentation的路徑設置爲您的CA文件作爲verify參數的值:

requests.get('https://tableau.mynetwork.lan', verify=tableau_cert) 

此外,請確保您有該文件是正確PEM encoded