对API的Python请求给出了SSL错误

时间:2017-10-04 08:57:40

标签: python ssl python-requests

我正在使用Python2.7,我需要访问某个API(Nuagen):https://nuagenetworks.github.io/vsd-api-documentation/usage.html

在文档中,他们说如下:

  

获取API密钥。   要获取和API密钥,第一步是进行/ me API调用。此API调用返回有关正在使用的帐户的信息。

    GET /me HTTP/1.1
    X-Nuage-Organization: my company
    Content-Type: application/json
    Authorization: $AUTHORIZATION_STRING
  

/ me API的授权字符串必须格式如下:

    $AUTHORIZATION_STRING = Basic base64($LOGIN:$PASSWORD)

所以我尝试以下面的方式构建我的请求;

import requests

url = 'https://an.ip.add.ress:8443/nuage/api/v4_0/me'
user = 'myuser'
passw = 'mypass'
cps = 'myorganization'

headers = {
    "Authorization": "Basic d29jdTpjdXdv",
    "Cache-Control": "no-cache",
    "Content-Type": "application/json",
    "X-Nuage-Organization": "csp",
}


response = requests.get(url, auth=(user, passw), headers=headers)
# Also tried with:
# response = requests.get(url, headers=headers)

但是,我总是收到这个错误:

requests.exceptions.SSLError: bad handshake: Error([('SSL routines', 'SSL3_GET_SERVER_CERTIFICATE', 'certificate verify failed')],)

有关如何使用Python请求访问此API的任何想法?或者其他任何方式?

0 个答案:

没有答案