Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

调用查询实例列表api报错 #137

Open
JungleWolfz opened this issue Jul 26, 2022 · 1 comment
Open

调用查询实例列表api报错 #137

JungleWolfz opened this issue Jul 26, 2022 · 1 comment

Comments

@JungleWolfz
Copy link

代码如:
`# 解决腾讯自签名证书问题 message:[SSL: CERTIFICATE_VERIFY_FAILED]
import ssl
ssl._create_default_https_context=ssl._create_unverified_context
import json
from tencentcloud.common import credential
from tencentcloud.common.profile.client_profile import ClientProfile
from tencentcloud.common.profile.http_profile import HttpProfile
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.cvm.v20170312 import cvm_client, models
try:
# 实例化一个认证对象,入参需要传入腾讯云账户secretId,secretKey,此处还需注意密钥对的保密
# 密钥可前往https://console.cloud.tencent.com/cam/capi网站进行获取
cred = credential.Credential("AKID4vHaTSE2hiz09A93dC512B4W9P3qlk865KK", "1ElYPvDna5bzPwC3oKS828a147PcUp7IEsI7wiWM")
# 实例化一个http选项,可选的,没有特殊需求可以跳过
httpProfile = HttpProfile()
httpProfile.endpoint = "cvm.tencentcloudapi.com"

# 实例化一个client选项,可选的,没有特殊需求可以跳过
clientProfile = ClientProfile()
clientProfile.httpProfile = httpProfile
# 实例化要请求产品的client对象,clientProfile是可选的
client = cvm_client.CvmClient(cred, "", clientProfile)

# 实例化一个请求对象,每个接口都会对应一个request对象
req = models.DescribeInstancesRequest()
params = {

}
req.from_json_string(json.dumps(params))

# 返回的resp是一个DescribeInstancesResponse的实例,与请求对象对应
resp = client.DescribeInstances(req)
# 输出json格式的字符串回包
print(resp.to_json_string())

except TencentCloudSDKException as err:
print(err)`

报错:

[TencentCloudSDKException] code:ClientNetworkError message:HTTPSConnectionPool(host='cvm.tencentcloudapi.com', port=443): Max retries exceeded with url: / (Caused by ProxyError('Cannot connect to proxy.', timeout('_ssl.c:1029: The handshake operation timed out'))) requestId:None

通过apiexplore调用 也报了后端服务错误
https://console.cloud.tencent.com/api/explorer?Product=cvm&Version=2017-03-12&Action=DescribeInstances

@zqfan
Copy link
Member

zqfan commented Aug 2, 2022

这是证书报错,服务端的证书是没有问题的。如果你是自行编译安装的python,则可能是编译参数忘了加上ssl相关的配置了。另外就是考虑是否改动过机器上的ssl证书文件

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants