我正在尝试运行一个连接到myhost.comapny.com:8443的python脚本,但它在运行时给出了ssl证书错误
(Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1122)')))
我的代码如下:
import requests
url = "https://myhost.comapny.com:8443/environments/test/deplpyments"
payload={}
files=[
('request',('test.yaml',open('test.yaml','rb'),'application/octet-stream'))
]
headers = {
'Content-Type': 'multipart/form-data',
'Authorization': 'token'
}
response = requests.request("POST", url, headers=headers, data=payload, files=files,verify="/user/test/company.cert")
print(response.text)
我已将证书添加为:
openssl s_client -showcerts -connect myhost.comapny.com:8443 </dev/null 2>/dev/null | openssl x509 -text >company.cert
但它仍然不起作用,同样的错误也随着ssl验证失败而来。似乎我没有正确生成证书。有人能告诉我如何正确生成证书吗?
1条答案
按热度按时间h79rfbju1#
您是否需要验证证书?如果没有,您可以尝试设置“verify=false”。